package inheritance;

public abstract class Shape implements Comparable {
    public abstract double area();

    public abstract double perimeter();

    public double semiperimeter() {
        return perimeter() / 2;
    }

    public int compareTo(Object rhs) {
        Shape other = (Shape) rhs;
        double diff = area() - other.area();

        if (diff == 0)
            return 0;
        else if (diff < 0)
            return -1;
        else
            return 1;
    }

    public double area2() {
        throw new UnsupportedOperationException();
    }
}
