... 3
 4   public class CommissionEmployee extends Employee {
 5      private double grossSales; // gross weekly sales
 6      private double commissionRate; // commission percentage
 7
 8      // constructor
9      public CommissionEmployee(String firstName, String lastName,
10         String socialSecurityNumber, double grossSales,
11         double commissionRate) {
12         super(firstName, lastName, socialSecurityNumber);
13
14         if (commissionRate <= 0.0 || commissionRate >= 1.0) // validate
15            throw new IllegalArgumentException(
16               "Commission rate must be > 0.0 and < 1.0");
17         }
18
19         if (grossSales < 0.0) { // validate
20            throw new IllegalArgumentException("Gross sales must be >= 0.0");
21         }
22
23         this.grossSales = grossSales;
24         this.commissionRate = commissionRate;
25      }
26
27      // set gross ...

Get Java How To Program, Late Objects, 11th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.