package com.hithomelabs.princeton1.module5;

import java.util.Objects;

public class Apple implements Comparable<Apple> {
    private int size;

    public Apple(int size) {
        this.size = size;
    }

    @Override
    public boolean equals(Object obj) {
        if(this == obj) return true;
        if (obj == null || this.getClass() != obj.getClass())
            return false;
        Apple that = (Apple) obj;
        return Objects.equals(this.size, that.size);
    }

    @Override
    public int hashCode() {
        return Objects.hash(size);
    }

    @Override
    public String toString() {
        return "An apple of size " + size;
    }

    @Override
    public int compareTo(Apple that) {
        if (this.size < that.size) return -1;
        else if (this.size == that.size) return 0;
        else return 1;
    }
}
