G.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. G.6), which contains a first name, last name, social security number, gross sales amount, commission rate and base salary. Class BasePlusCommissionEmployee
’s public
services include a BasePlusCommissionEmployee
constructor (lines 15–25) and methods earnings
(lines 112–115) and toString
(lines 118–127). Lines 28–109 declare public
get and set methods for the class’s private
instance variables (declared in lines 7–12) firstName
, lastName
, socialSecurityNumber
, grossSales
, commissionRate
and baseSalary
. These variables and ...
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.