home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / VCSAMPL.BIN / Employee.java < prev    next >
Text File  |  1997-08-23  |  990b  |  49 lines

  1. /**
  2.  * A completely constructed employee data object.
  3.  */
  4.  
  5. public class Employee
  6. {
  7.     public Name name;
  8.     public Section section;
  9.     public SSN ssn;
  10.  
  11.     final static int NAME_FLD = 0;
  12.     final static int AGE_FLD = 1;
  13.     final static int SSN_FLD = 2;
  14.  
  15.     public Employee(Name n, Section a, SSN s)
  16.     throws InvalidEmployeeException
  17.     {
  18.         name = n;
  19.         if (!name.isValid()) throw new InvalidEmployeeException();
  20.         section = a;
  21.         if (!section.isValid()) throw new InvalidEmployeeException();
  22.         ssn = s;
  23.         if (!ssn.isValid()) throw new InvalidEmployeeException();
  24.     }
  25.  
  26.     public Employee(String n, String a, String s)
  27.     throws InvalidEmployeeException
  28.     {
  29.         this(new Name(n), new Section(a), new SSN(s));
  30.     }
  31.  
  32.     public String toString()
  33.     {
  34.         String s;
  35.         s = (name.value()).trim();
  36.         s += " ";
  37.         s += (String.valueOf(section.value())).trim();
  38.         s += " ";
  39.         s += (ssn.value()).trim();
  40.         s += "\r\n";
  41.         return s;
  42.     }
  43. }
  44.  
  45. /**
  46.  * A state-ful list of employee data objects.
  47.  */
  48.  
  49.