9.4.2 Creating and Using a BasePlusCommissionEmployee Class
We now discuss the second part of our introduction to inheritance by declaring and testing (a completely new and independent) class
BasePlusCommissionEmployee (Fig. 9.6), which contains a first name, last name, social security number, gross sales amount, commission rate and base salary. Class
public services include a
BasePlusCommissionEmployee constructor (lines 15–42) and methods
earnings (lines 111–114) and
toString (lines 117–126). Lines 45–108 declare
public get and set methods for the class’s
private instance variables (declared in lines 7–12)
baseSalary. These variables and ...
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.