// Programs from class are posted on the lecture summaries webpage.

/** An instance is a worker in a certain organization */
public class Worker {
     private String lname; // Last name. Never null, use ""
                           // if it's unknown
     private int ssn;      // Social security no.
                           // in 0..999999999
     private Worker boss;  // The worker's boss --null if none
     
     private static int numWorkers; // how many workers exist

    
     /* Class invariant: the collection of meaning of fields and
        constraints on them, written as comments on the field as above */
     
     /** Constructor: an instance with last name n, soc sec
            number s, and boss b.
         Precondition: n is not null; use "" if unknown
                       s is in 0..999999999
                       b is null if this Worker has none */
     public Worker(String n, int s, Worker b) {
         lname= n;
         ssn= s;
         boss= b;
         numWorkers= numWorkers + 1;
     }
     
     /** = the last name of this worker */
     public String getLname() {
         return lname;
     }
     
     /** = the boss of this worker */
     public Worker getBoss() {
         return boss;
     }
     
     /** = last 4 digits of soc sec number */
     public int getSsn() {
         return ssn % 10000;
     }
     
     /** = the usual starting salary */
     public static int getDefaultSalary() {
       return 50000;
     }

     /** = b is the boss of this worker */
     public boolean isEmployeeOf(Worker b) {
       return b == boss;  // equivalently, b == this.boss
     }
     
     /** = this worker is the boss of c */
     public boolean isEmployeeOf(Worker c) {
       return this == c.boss;
     }
     
     /** = b is the boss of c */
     public static boolean isBoss(Worker b, Worker c) {
       return b == c.boss;
     }
 }