package UE02_100924_Collections_TreeSet;

public class Person implements Comparable<Person> {
    public String vorname;
    public String famname;

    public Person(String vn, String fn) {
        this.vorname = vn.trim();
        this.famname = fn.trim();
    }

    @Override
    public String toString() {
        return "Person{" + "vorname='" + vorname + '\'' + ", famname='" + famname + '\'' + '}';
    }

    @Override
    public int compareTo(Person o) {
        int compare = this.famname.compareToIgnoreCase(o.famname);
        if (compare != 0) return compare;
        return this.vorname.compareToIgnoreCase(o.vorname);
    }
}
