// interface--------abstract class-----------class // abstract---------------------------concrete // Simple interface for a shape public abstract class Shape implements Comparable { private String name; public Shape(String name) { this.name = name; } public abstract double area(); // compares this rectangle to other by area // pre: other != null public final int compareTo(Shape other) { if (this.area() < other.area()) { return -1; } else if (this.area() > other.area()) { return 1; } else { return 0; } } public final String toString() { return name + " of area " + String.format("%.3f", area()); } }