(week of Mar 23-- 27)
The purpose of this lab is to practice again inheritance and polymorphism.
There is only one part in Lab 8.
Description of the Problem
(Accounts Payable System Modification)
In this exercise, we modify the accounts payable application.
The application should still process two Invoice objects, but now should process one object of each of the four Employee subclasses. If the object currently being processed is a BasePlusCommissionEmployee, the application should increase the BasePlusCommissionEmployee’s base salary by 10%. Finally, the application should output the payment amount for each object.
Download the Lab 8 Program Template here and Complete the following steps to create the new application.
a) Modify classes
HourlyEmployee and CommissionEmployee to place them in the Payable hierarchy as subclassesof the version of
Employee that implements Payable. [Hint: Change the name of methodearnings
to getPaymentAmount in each subclass so that the class satisfies its inherited contract with interfacePayable
.]
b) Modify class
BasePlusCommissionEmployee such that it extends the version of class CommissionEmployeecreated in
Part a.
c) Modify PayableInterfaceTest to polymorphically process two Invoices, one SalariedEmployee, one
HourlyEmployee, one CommissionEmployee and one BasePlusCommissionEmployee. First output a string
representation of each Payable object. Next, if an object is a BasePlusCommissionEmployee, increase its base
salary by 10%. Finally, output the payment amount for each Payable object.