1  /*
  2   *  File:  QuadrilateralTest2.java
  3   *
  4   *  Drawing quadrilaterals (an exercise)
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   *  
  8   */
  9  
 10  import java.applet.Applet;
 11  import java.awt.Graphics;
 12  
 13  public class QuadrilateralTest2 extends Applet {
 14  
 15     // create references to four quadrilaterals:
 16     private Quadrilateral quad1, quad2, quad3, quad4;
 17     
 18     public void init() {
 19     
 20        // instantiate a rectangle (a kind of quadrilateral):
 21        quad1 = new Quadrilateral( 25, 25, 125, 25, 125, 75, 25, 75 );
 22        // instantiate a parallelogram (another kind of quadrilateral):
 23        quad2 = new Quadrilateral( 165, 25, 265, 25, 250, 75, 150, 75 );
 24  
 25        // instantiate a square (a kind of rectangle):
 26        quad3 = new Quadrilateral( 50, 100, 100, 100, 100, 150, 50, 150 );
 27        // instantiate a rhombus (a kind of parallelogram):
 28        quad4 = new Quadrilateral( 195, 110, 245, 110, 215, 150, 165, 150 );
 29  
 30     }
 31     
 32     public void paint( Graphics g ) {
 33  
 34        // draw the first quadrilateral:
 35        quad1.draw( g );
 36  
 37        // fill the second quadrilateral:
 38        quad2.fill( g );
 39  
 40        // draw the third quadrilateral:
 41        quad3.draw( g );
 42  
 43        // fill the fourth quadrilateral:
 44        quad4.fill( g );
 45  
 46     }
 47     
 48  }