public class BasePlusCommissionEmployee5 extends CommissionEmployee4
1: // Fig. 9.16: BasePlusCommissionEmployee5.java
2: // BasePlusCommissionEmployee5 class declaration.
3:
4: public class BasePlusCommissionEmployee5 extends CommissionEmployee4
5: {
6: private double baseSalary; // base salary per week
7:
8: // six-argument constructor
9: public BasePlusCommissionEmployee5( String first, String last,
10: String ssn, double sales, double rate, double salary )
11: {
12: super( first, last, ssn, sales, rate );
13: setBaseSalary( salary ); // validate and store base salary
14:
15: System.out.printf(
16: "\nBasePlusCommissionEmployee5 constructor:\n%s\n", this );
17: } // end six-argument BasePlusCommissionEmployee5 constructor
18:
19: // set base salary
20: public void setBaseSalary( double salary )
21: {
22: baseSalary = ( salary < 0.0 ) ? 0.0 : salary;
23: } // end method setBaseSalary
24:
25: // return base salary
26: public double getBaseSalary()
27: {
28: return baseSalary;
29: } // end method getBaseSalary
30:
31: // calculate earnings
32: public double earnings()
33: {
34: return getBaseSalary() + super.earnings();
35: } // end method earnings
36:
37: // return String representation of BasePlusCommissionEmployee5
38: public String toString()
39: {
40: return String.format( "%s %s\n%s: %.2f", "base-salaried",
41: super.toString(), "base salary", getBaseSalary() );
42: } // end method toString
43: } // end class BasePlusCommissionEmployee5
44:
45:
46: /**************************************************************************
47: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
48: * Pearson Education, Inc. All Rights Reserved. *
49: * *
50: * DISCLAIMER: The authors and publisher of this book have used their *
51: * best efforts in preparing the book. These efforts include the *
52: * development, research, and testing of the theories and programs *
53: * to determine their effectiveness. The authors and publisher make *
54: * no warranty of any kind, expressed or implied, with regard to these *
55: * programs or to the documentation contained in these books. The authors *
56: * and publisher shall not be liable in any event for incidental or *
57: * consequential damages in connection with, or arising out of, the *
58: * furnishing, performance, or use of these programs. *
59: *************************************************************************/