10.9.5 Modifying Class SalariedEmployee for Use in the Payable Hierarchy

Figure 10.14 contains a modified SalariedEmployee class that extends Employee and fulfills superclass Employee’s contract to implement Payable method getPaymentAmount. This version of SalariedEmployee is identical to that of Fig. 10.5, but it replaces method earnings with method getPaymentAmount (lines 39–43). Recall that the Payable version of the method has a more general name to be applicable to possibly disparate classes. (If we included the remaining Employee subclasses from Section 10.5HourlyEmployee, CommissionEmployee and BasePlusCommissionEmployee—in this example, their earnings methods should also be renamed getPaymentAmount. We leave these modifications to ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.