public class FullName implements Comparable<FullName> {
  private String firstName;
  private String lastName;
  public FullName(String first, String last) {
    firstName = first;
    lastName = last;
  } // end constructor
  
  public int compareTo(FullName rhs) {
  // Postcondition: returns 0 if all fields match
  // if lastName equals rhs.lastName and
  // firstName is greater than rhs.firstName
  // returns -1 if lastName is less than rhs.lastName or
  // if lastName equals rhs.lastName and
  // firstName is less than rhs.firstName
  // object.
  // Throws ClassCastException if rhs cannot be cast to Fullname
    FullName other = (FullName)rhs;
    if (lastName.compareTo(((FullName)other).lastName)==0){
      return firstName.compareTo(((FullName)other).firstName);
    }
    else {
      return lastName.compareTo(((FullName)other).lastName);
    } // end if
  } // end compareTo

} // end class FullName