Modify class Employee from Exercise 10.17 so that it implements the Payable interface of Fig. 10.11. Replace
Question:
Modify class Employee from Exercise 10.17 so that it implements the Payable interface of Fig. 10.11. Replace the Salaried-Employee objects in the application of Fig. 10.14 with the Employee objects from Exercise 10.17 and demonstrate processing the Employee and Invoice objects polymorphically.
Exercise 10.17
Exercise 9.16 asked you to remodel Chapter 9’s CommissionEmployee–BasePlusCommissionEmployee inheritance hierarchy as a class Employee in which each Employee has a different CompensationModel object. In this exercise, reimplement Exercise 9.16’s CompensationModel class as an interface that provides a public abstract method earnings that receives no parameters and returns a double. Then create the following classes that implement interface CompensationModel:
In your test application, create Employee objects with each of the CompensationModels described above, then display each Employee’s earnings. Next, change each Employee’s CompensationModel dynamically and redisplay each Employee’s earnings.
Fig. 10.11
Fig. 10.14
Step by Step Answer:
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates