/* * File: Rectangle.java * * Rectangle class * * Copyright: Northeast Parallel Architectures Center * */ // A rectangle is a quadrilateral with four right angles: public class Rectangle extends Quadrilateral { // Rectangle constructor #1: public Rectangle( int x, int y, int w, int h ) { // invoke the no-argument constructor of the superclass: super(); // the 'this' reference is optional: this.addPoint( x, y ); this.addPoint( x + w, y ); this.addPoint( x + w, y + h ); this.addPoint( x, y + h ); } // Rectangle constructor #2: public Rectangle( int x, int y, int w, int h, double theta ) { // invoke Rectangle constructor #1: this( x, y, w, h ); // rotate the rectangle theta radians: this.rotate( theta ); } }