10.5.4 Concrete Subclass CommissionEmployee

Class CommissionEmployee (Fig. 10.7) extends class Employee (line 4). The class includes a constructor (lines 10–25) that takes a first name, a last name, a social security number, a sales amount and a commission rate; set methods (lines 28–34 and 43–50) to assign valid new values to instance variables commissionRate and grossSales, respectively; get methods (lines 37–40 and 53–56) that retrieve the values of these instance variables; method earnings (lines 59–63) to calculate a CommissionEmployee’s earnings; and method toString (lines 66–73), which returns the employee’s type, namely, "commission employee: " and employee-specific information. The constructor also passes the first name, last name ...

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.