// Class to represent a square public class Square implements Shape { private double side; public Square(double side) { this.side = side; } // returns the area of this square public double area() { return side * side; } // compares this square to other by area // pre: other != null public int compareTo(Shape other) { if (this.area() < other.area()) { return -1; } else if (this.area() > other.area()) { return 1; } else { return 0; } } public String toString() { return "square of area " + String.format("%.3f", area()); } }