package UE02_100924_Collections_TreeSet;

public class Buch implements Comparable<Buch> {
    String title;
    String autor;
    int price;

    public Buch(String title, String autor, int price) {
        this.title = title;
        this.autor = autor;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Buch{" + "title='" + title + '\'' + ", autor='" + autor + '\'' + ", price=" + price + '}';
    }

    @Override
    public int compareTo(Buch o) {
        if (this.price != o.price) return Integer.compare(this.price, o.price);
        int compare = this.title.compareTo(o.title);
        if (compare != 0) return compare;
        return this.autor.compareTo(o.autor);
    }
}
