public class Person implements Comparable<Person> {
    private final String firstName;
    private final String lastName;
    private static final int BEFORE = -1;
    private static final int EQUAL = 0;
    private static final int AFTER = 1;
    public static final Person NO_NAME = new Person("", "");
    Person(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }
    String getFirstName() {
        return firstName;
    }
    String getLastName() {
        return lastName;
    }
    @Override
    public int compareTo(Person other) {
        int c_ln = this.lastName.compareToIgnoreCase(other.lastName);
        if (c_ln < 0) {
            return BEFORE;
        }
        if (c_ln > 0) {
            return AFTER;
        }
        int c_fn = this.firstName.compareToIgnoreCase(other.firstName);
        if (c_fn < 0) {
            return BEFORE;
        }
        if (c_fn > 0) {
            return AFTER;
        }
        return EQUAL;
    }
    @Override
    public boolean equals(Object obj) {
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Person other = (Person) obj;
        return (this.firstName.toLowerCase().equals(other.firstName.toLowerCase())
                && this.lastName.toLowerCase().equals(other.lastName.toLowerCase()));
    }
    @Override
    public int hashCode() {
        return this.compareTo(NO_NAME);
    }
    @Override
    public String toString() {
        return (lastName + ", " + firstName);
    }
}
