Question: Write the differences between Figure 9.4 and Figure 9.10 (both are implementation of CommissionEmployee class) This is Figure 9.4 This is Figure 9.10 only for
only for demonstration purposes. Overview of Class ComissionEmployee's Methods and Inntmee Variables Class CommissionEnployee's public services include a constructor nes 13-34) and methods earnings (ines 87-90) and tostring 0ines 93-101), Lines 37-52 declare pub- nie err methods for the class's final instance variables (declared in lines 6-8) firstNane, lastName and social SecurityNumber. These three instance variables are declared final because they do not need to be modified after they're initialized-this is also why we do 366 Chapter 9 Object-oriented Programming Inheritance corresponding ser methods. Lines 55-84 declare public ser and get methods for the class's grosssales and commissionRate instance variables (declared in lines9-10) The class declares its instance variables as private, so objects of other classes cannot di rectly access these variables, 9.4: Commiss on Employee java 2 Commission Employee ss represents an employee paid a percentage of gross sales 4 public class CommissionEmployee extends object private final String firstNane private final String lastName private final String socialSecurityNunbe private double grosssales: gross weekly sales 10 private double comissionRate: commission percentage five-argument constructor 13 public Commission Employee CString firstName, String lastName, String social SecurityNumber, double grosssales. ssionRate) implicit cal to object's default constructor occurs here if grossSales is invalid throw exception if (gross sales 0.0) throw new niegalArgumentExcept tion( "Gross sales must be 0.0 if comi sionkate is invalid throw exception if (commission Rate onRate 1.0) tion "Commission rate must be 0.0 and 1.0") this firstName firstName this last Name last Name this social SecurityNumbe r social SecurityNumber this gross Sales gresssales cosmissionRate this commission Rate end constnactor return first name public string getFirstNameo return firstNase return last name lastName Fig. 9.4 I ComissionEmployee class represents an employee paid a percentage of gross sales
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
