Programming Exercise



Create a new program with a nested class named PrintFunc that extends class Print from Exercise 6.2. In addition to just printing the value, class PrintFunc should first apply a Function object on the value. Class PrintFunc should have a constructor that takes an instance of Function type as a parameter. The evaluate() method of class PrintFunc should use the Function object on its argument. The evaluate() method should print and return the result. The evaluate() method in superclass Print should be used to print the value.

The program should behave like the one in Exercise 6.2, but this time use the nested class PrintFunc instead of class Print.