Problem

(Accounts Payable System Modification) It’s possible to include the functionality of the p...

(Accounts Payable System Modification) It’s possible to include the functionality of the payroll application (Figs.) in the accounts payable application without modifying Employee subclasses SalariedEmployee, HourlyEmployee, CommissionEmployee or BasePlusCommission-Emplyee. To do so, you can modify class Employee () to implement interface Payable and declare method getPaymentAmount to invoke method earnings. Method getPaymentAmount would then be inherited by the subclasses in the Employee hierarchy. When getPaymentAmount is called for a particular subclass object, it polymorphically invokes the appropriate earnings method for that subclass. Reimplement Exercise  using the original Employee hierarchy from the payroll application of Figs. Modify class Employee as described in this exercise, and do not

modify any of class Employee’s subclasses.

Fig. | Employee abstract superclass.

Fig. | SalariedEmployee concrete class extends abstract class Employee.

Fig. | HourlyEmployee class derived from Employee.

Fig. | CommissionEmployee class derived from Employee.

Fig. | BasePlusCommissionEmployee class extends CommissionEmployee.

Fig. | Employee hierarchy test program.

Exercise

(Accounts Pa yable System Modification) In this exercise, we modify the accounts payable application of to include the complete functionality of the payroll application of Figs.. 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 Base-PlusCommissionEmployee, the application should increase the BasePlusCommissionEmployee’s base

salary by 10%. Finally, the application should output the payment amount for each object. Complete the following steps to create the new application:

a) Modify classes HourlyEmployee (Fig.) and CommissionEmployee (Fig.) to place them in the Payable hierarchy as subclasses of the version of Employee (Fig.) that implements Payable. [Hint: Change the name of method earnings to getPayment-Amount in each subclass so that the class satisfies its inherited contract with interface Payable.]

Fig. | HourlyEmployee class derived from Employee.

Fig. | CommissionEmployee class derived from Employee.

Fig. | Employee class that implements Payable.


b) Modify class BasePlusCommissionEmployee (Fig.) such that it extends the version of class CommissionEmployee created in part (a).

Fig. | BasePlusCommissionEmployee class extends CommissionEmployee.


c) Modify PayableInterfaceTest (Fig.) to polymorphically process two Invoices, one SalariedEmployee, one HourlyEmployee, one CommissionEmployee and one Base-PlusCommissionEmployee. 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.

Fig. | Payable interface test program processing Invoices and Employees polymorphically.

Fig. | Payable interface declaration.

Fig. | Invoice class that implements Payable.

Fig. | Employee class that implements Payable.

Fig. | SalariedEmployee class that implements interface Payable method getPaymentAmount.

Fig. | Payable interface test program processing Invoices and Employees polymorphically.

Fig. | Employee abstract superclass.

Fig. | SalariedEmployee concrete class extends abstract class Employee.

Fig. | HourlyEmployee class derived from Employee.

Fig. | CommissionEmployee class derived from Employee.

Fig. | BasePlusCommissionEmployee class extends CommissionEmployee.

Fig. | Employee hierarchy test program.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 10
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT