public class Rectangle extends Quadrilateral { private double width, height; public Rectangle(Point p1, Point p2, Point p3, Point p4) { super(p1, p2, p3, p4); width = p1.distTo(p2); height = p2.distTo(p3); // should check that all angles are right angles via slopes neg recip // or check both widths equal, both heights equal, both diags equal } public Rectangle(Point p1, Point p3) { // Sides parallel to the axes super(p1, new Point(p3.x,p1.y), p3, new Point(p1.x,p3.y)); width = Math.abs(p1.x-p3.x); height = Math.abs(p1.y-p3.y); // Nothing to check } public double getWidth() { return width; } public double getHeight() { return height; } public double area() { return width * height; } } // Local Variables: // c-basic-offset: 4 // compile-command: "javac Rectangle.java" // End: