Source of BasePlusCommissionEmployeeTest.java


  1: // Fig. 9.7: BasePlusCommissionEmployeeTest.java
  2: // Testing class BasePlusCommissionEmployee.
  3: 
  4: public class BasePlusCommissionEmployeeTest 
  5: {
  6:    public static void main( String args[] ) 
  7:    {
  8:       // instantiate BasePlusCommissionEmployee object
  9:       BasePlusCommissionEmployee employee = 
 10:          new BasePlusCommissionEmployee( 
 11:          "Bob", "Lewis", "333-33-3333", 5000, .04, 300 );
 12:       
 13:       // get base-salaried commission employee data
 14:       System.out.println( 
 15:          "Employee information obtained by get methods: \n" );
 16:       System.out.printf( "%s %s\n", "First name is",
 17:          employee.getFirstName() );
 18:       System.out.printf( "%s %s\n", "Last name is", 
 19:          employee.getLastName() );
 20:       System.out.printf( "%s %s\n", "Social security number is", 
 21:          employee.getSocialSecurityNumber() );
 22:       System.out.printf( "%s %.2f\n", "Gross sales is", 
 23:          employee.getGrossSales() );
 24:       System.out.printf( "%s %.2f\n", "Commission rate is",
 25:          employee.getCommissionRate() );
 26:       System.out.printf( "%s %.2f\n", "Base salary is",
 27:          employee.getBaseSalary() );
 28: 
 29:       employee.setBaseSalary( 1000 ); // set base salary
 30:       
 31:       System.out.printf( "\n%s:\n\n%s\n", 
 32:          "Updated employee information obtained by toString", 
 33:          employee.toString() );
 34:    } // end main
 35: } // end class BasePlusCommissionEmployeeTest
 36: 
 37: 
 38: /**************************************************************************
 39:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 40:  * Pearson Education, Inc. All Rights Reserved.                           *
 41:  *                                                                        *
 42:  * DISCLAIMER: The authors and publisher of this book have used their     *
 43:  * best efforts in preparing the book. These efforts include the          *
 44:  * development, research, and testing of the theories and programs        *
 45:  * to determine their effectiveness. The authors and publisher make       *
 46:  * no warranty of any kind, expressed or implied, with regard to these    *
 47:  * programs or to the documentation contained in these books. The authors *
 48:  * and publisher shall not be liable in any event for incidental or       *
 49:  * consequential damages in connection with, or arising out of, the       *
 50:  * furnishing, performance, or use of these programs.                     *
 51:  *************************************************************************/