/**
 * Simple class that represents a Person.
 *   @author Dave Reed
 *   @version 10/1/24
 */
public class Person implements Comparable<Person>{
	private String lastName;
	private String firstName;
	private int age;

	/**
	 * Constructs a Person object.
	 *   @param first their first name
	 *   @param last their last name
	 *   @param age their age
	 */
	public Person(String first, String last, int age) {
		this.lastName = last;
		this.firstName = first;
		this.age = age;
	}

	/**
	 * Accessor method for the Person's last name
	 *   @return their last name
	 */
	public String getLast() {
		return this.lastName;
	}

	/**
	 * Accessor method for the Person's first name
	 *   @return their first name
	 */
	public String getFirst() {
		return this.firstName;
	} 

	/**
	 * Accessor method for the Person's age.
	 *   @return their age
	 */
	public int getAge() {
		return this.age;
	}

	/** 
	 * Converts the object to a printable String.
	 *   @return the String representation
	 */
	public String toString() {
		return this.firstName + " " + this.lastName + " (" + this.age + ")";
	}

	/**
	 * Comparison operator for Persons, based on last name, then first, then age.
	 *   @return neg if comes before other, 0 if same, pos if comes after other
	 */
	public int compareTo(Person other) {
		if (!this.lastName.equals(other.lastName)) {
			return this.lastName.compareTo(other.lastName);
		}
		else if (!this.firstName.equals(other.firstName)) {
			return this.firstName.compareTo(other.firstName);
		}
		else {
			return this.age - other.age;
		}
	}
}
