/** A rectangle with a base point, width and height. @author Greg Vogl last modified 2003-10-14 */ public class RectangleShape extends Shape { // constructors // override defaults public RectangleShape() { super(); width = 1; height = 1; } public RectangleShape(double x, double y) { super(); width = x; height = y; } // additional constructors public RectangleShape(double x, double y, double width, double height) { super(x, y); this.width = width; this.height = height; } // accessors public double width() { return width; } public double height() { return height; } // calculations public double perimeter() { return 2 * (width + height); } public double area() { return width * height; } // toString public String toString() { return super.toString() + "[width=" + width + ",height=" + height + "]"; } // private variables private double width; private double height; }