package personsorter;

public class Person implements Comparable<Person>{
	String firstName;
	String lastName;
	Integer birthYear;
	
	public Person(String firstName, String lastName, Integer birthYear) {
		super();
		this.firstName = firstName;
		this.lastName = lastName;
		this.birthYear = birthYear;
	}
	
	public Integer getBirthYear() {
		return birthYear;
	}
	
	public String getFirstName() {
		return firstName;
	}
	
	public String getLastName() {
		return lastName;
	}
	
	@Override
	public int compareTo(Person o) {
		//moze efikasnije (cuvamo compareTo rezultat u promenljivoj
		if(this.lastName.compareTo(o.lastName)!=0)
			return this.lastName.compareTo(o.lastName);
		if(this.firstName.compareTo(o.firstName)!=0)
			return this.firstName.compareTo(o.firstName);
		return this.birthYear.compareTo(o.birthYear);
	}
	
	@Override
	public String toString() {
		return lastName+" "+firstName+" ("+birthYear+")";
	}
}
