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

I // Fig. 10.11: Payable.java 2 // Payable interface declaration. 3 4 public interface Payable { 5 public

Fig. 10.14I // Fig. 10.14: PayableInterfaceTest.java 2 // Payable interface test program processing Invoices and 3 //

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Java How To Program Late Objects Version

ISBN: 9780136123712

8th Edition

Authors: Paul Deitel, Deitel & Associates

Question Posted: