G.12.5. Modifying Class SalariedEmployee for Use in the Payable Hierarchy
Figure G.26 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. G.17, but it replaces method earnings
with method getPaymentAmount
(lines 34–38). Recall that the Payable
version of the method has a more general name to be applicable to possibly disparate classes. The remaining Employee
subclasses (e.g., HourlyEmployee
, CommissionEmployee
and BasePlusCommissionEmployee
) also must be modified to contain method getPaymentAmount
in place of earnings
to reflect the fact that Employee
now implements Payable
. We leave ...
Get Android™ How to Program, Second 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.