Source of Employee.java


  1: // Fig. 8.8: Employee.java
  2: // Employee class with references to other objects.
  3: 
  4: public class Employee 
  5: {
  6:    private String firstName;
  7:    private String lastName;
  8:    private Date birthDate;
  9:    private Date hireDate;
 10: 
 11:    // constructor to initialize name, birth date and hire date
 12:    public Employee( String first, String last, Date dateOfBirth, 
 13:       Date dateOfHire )
 14:    {
 15:       firstName = first;
 16:       lastName = last;
 17:       birthDate = dateOfBirth;
 18:       hireDate = dateOfHire;
 19:    } // end Employee constructor
 20: 
 21:    // convert Employee to String format
 22:    public String toString()
 23:    {
 24:       return String.format( "%s, %s  Hired: %s  Birthday: %s", 
 25:          lastName, firstName, hireDate, birthDate );
 26:    } // end method toEmployeeString
 27: } // end class Employee
 28: 
 29: 
 30: 
 31: /**************************************************************************
 32:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 33:  * Pearson Education, Inc. All Rights Reserved.                           *
 34:  *                                                                        *
 35:  * DISCLAIMER: The authors and publisher of this book have used their     *
 36:  * best efforts in preparing the book. These efforts include the          *
 37:  * development, research, and testing of the theories and programs        *
 38:  * to determine their effectiveness. The authors and publisher make       *
 39:  * no warranty of any kind, expressed or implied, with regard to these    *
 40:  * programs or to the documentation contained in these books. The authors *
 41:  * and publisher shall not be liable in any event for incidental or       *
 42:  * consequential damages in connection with, or arising out of, the       *
 43:  * furnishing, performance, or use of these programs.                     *
 44:  *************************************************************************/