// Second version of the Worker class

/** An instance is a worker in a certain organization */
public class Worker {
    
    private String name; // Last name (null if unknown/none, o.w. at least one character)
    private int ssn; // Social security #: in 0..999999999
    private Worker boss;  // Immediate boss (null if none)

       
     /** Constructor: a worker with 
      * last name n (null if unknown/none), 
      * SSN s, 
      * and boss b (null if none).
      * Precondition: if n is not null, it has at least one character.
      * Precondition: s in 0..999999999 with no leading zeros,
      * so SSN 012-34-5678 should be given as 12345678.*/
    public Worker(String n, int s, Worker b) {
        name= n;
        ssn= s;
        boss= b;
        
    }
    
    
    /** = last name of this Worker (null if unknown/none)*/
    public String getName() {
        return name;
    }
    
    /** Set the last name of this Worker to ln */
    public void setName(String ln) {
        name= ln;
    }
    
    /** = last 4 digits of the SSN (no leading zeros) */
    public int getSSN4() {
       return ssn % 10000; 
    }
    
    // no setter method for ssn.
    
    
    /** set boss of this Worker to b */
    public void setBoss(Worker b) {
        boss= b;
    }
    
    /** = the boss of this Worker (null if none) */
    public Worker getBoss() {
        return boss; // #@ should be boss, show what mistake does
    }
    
    /** = "b is the boss of c".
      * Precondition: b and c are both non-null */
    public static boolean isBoss(Worker b, Worker c) {
        return b==c.getBoss();
    }
    
    /** = representation of this Worker as last name, comma, space, 
      * XXX-XX-s where s it the last 4 digits of the social security number
      * (leading zeros omitted), comma, space, the word "Boss:", 
      * space, String representation of boss (null if none) */
    public String toString() {
        return name + ", XXX-XX-" + getSSN4() + ", Boss: " + boss;
    }
}
