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.

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 //

I // Fig. 10.11: Payable.java 2 // Payable interface declaration. 3 4 public interface Payable { 5 public abstract double getPayment Amount(); // no implementation 6}

Step by Step Solution

3.27 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Based on the information that youve provided and the images you want to modify the Employee class from Exercise 1017 so that it implements the Payable interface from Fig 1011 The Payable interface inc... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java How To Program Late Objects Questions!