/** A concrete class that (1) extends the abstract Employee 
  class by adding a weeklySalary field and implementing the 
  abstract earnings() method; and (2) imeplements the Compare
  interface by providing an implementation of the compare()
  method
*/
public class CompareBoss extends Employee implements Compare {
  private double weeklySalary;  // weekly pay

  /** a constructor that initializes the fields fistName,
    lastName, and weeklySalary according to the
    respective parameters */
  public CompareBoss(String first, String last, double salary) {
    super(first, last);
    weeklySalary = salary;
  }

  /** implement the abstract earnings() method */
  public double earnings() {
    return weeklySalary;
  }

  /** override the toString() method */
  public String toString() {
    return super.toString() + ", wage = " + weeklySalary;
  }

  /** implements the compare() method of the Compare interface;
    it compares the invoking Boss object's name
    with x's name, return -1, 0, or 1, depending on
    respectively, smaller, equal, or larger in
    lexicographical order */
  public int compare(Object x) {
    if (getLastName().compareTo(((CompareBoss)x).getLastName()) < 0)
      // if the lastName is smaller      
      return -1;  
    else if (getLastName().compareTo(((CompareBoss)x).getLastName()) > 0) 
      // if the lastName is larger      
      return 1;   
    else if (getFirstName().compareTo(((CompareBoss)x).getFirstName()) < 0)
      // if equal last names but firstName smaller        
      return -1;  
    else if (getFirstName().compareTo(((CompareBoss)x).getFirstName()) > 0)
      // if equal last names but firstName larger        
      return 1;
    else  
      // must be equal last and first names
      return 0;
  }
}
