package sg;

/**
 * The <code>class Quadrilateral</code> defines a four-sided geometric
 * object.
 *
 * @version   2.0, 10 June 1997
 * @author    B. F. Caviness
 */
public class Quadrilateral implements Polygon
{
   /**
    * Member variables defining the four corners of the quadrilateral in
    * clockwise order starting with the upper left-hand corner.
    */
   protected Pixel p1, p2, p3, p4;	// Four corners in clockwise order

   /**
    * Zero-parameter constructor that initializes all corners of the 
    * quadrilateral to (0,0).
    */
   public Quadrilateral()
   { 
      p1 = new Pixel();
      p2 = new Pixel();
      p3 = new Pixel();
      p4 = new Pixel();
   }

   /**
    * Four-parameter constructor
    */
   public Quadrilateral( Pixel p1, Pixel p2, Pixel p3, Pixel p4 )
   {
       this();
       this.p1.x = p1.x; this.p1.y = p1.y;
       this.p2.x = p2.x; this.p2.y = p2.y;
       this.p3.x = p3.x; this.p3.y = p3.y;
       this.p4.x = p4.x; this.p4.y = p4.y;
   }

   /** Draws the quadrilateral.
    *
    * @param g simple graphics device on which quadrilateral is drawn.
    */
   public void paint( Graphics g )
   {
      g.drawLine( p1.x, p1.y, p2.x, p2.y );
      g.drawLine( p2.x, p2.y, p3.x, p3.y );
      g.drawLine( p3.x, p3.y, p4.x, p4.y );
      g.drawLine( p4.x, p4.y, p1.x, p1.y );
   }
}
