10.5.2 Concrete Subclass SalariedEmployee

Class SalariedEmployee (Fig. 10.5) extends class Employee (line 4) and overrides abstract method earnings (lines 38–42), which makes SalariedEmployee a concrete class. The class includes a constructor (lines 9–19) that receives a first name, a last name, a social security number and a weekly salary; a set method to assign a new nonnegative value to instance variable weeklySalary (lines 22–29); a get method to return weeklySalary’s value (lines 3235); a method earnings (lines 38–42) to calculate a SalariedEmployee’s earnings; and a method toString (lines 45–50), which returns a String including "salaried employee: " followed by employee-specific information produced by superclass Employee’s toString ...

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.