1  /*
  2   *  File:  Rectangle.java
  3   *
  4   *  Rectangle class
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   *  
  8   */
  9  
 10  // A rectangle is a quadrilateral with four right angles:
 11  public class Rectangle extends Quadrilateral {
 12  
 13     // Rectangle constructor #1:
 14     public Rectangle( int x, int y, int w, int h  ) {
 15   
 16        // invoke the no-argument constructor of the superclass:
 17        super();
 18   
 19        // the 'this' reference is optional:
 20        this.addPoint( x, y );
 21        this.addPoint( x + w, y );
 22        this.addPoint( x + w, y + h );
 23        this.addPoint( x, y + h );
 24   
 25     }
 26  
 27     // Rectangle constructor #2:
 28     public Rectangle( int x, int y, 
 29                       int w, int h,
 30                       double theta  ) {
 31   
 32        // invoke Rectangle constructor #1:
 33        this( x, y, w, h );
 34      
 35        // rotate the rectangle theta radians:
 36        this.rotate( theta );
 37   
 38     }
 39  
 40  }