package sg;


/**
 * The <code>class Trapezoid</code> defines a trapezoid object.
 * For simplicity, the two parallel sides of the trapezoid
 * are assumed to be horizontal.  The trapezoid is determined
 * by four points (p1, p2, p3, p4).  p1 is assumed to be the
 * upper left hand corner and the other points are assumed to
 * be listed in clockwise order.
 */
 
public class Trapezoid extends Quadrilateral
{

  /**
   * Four-parameter constructor.
   * Throws IllegalArgumentException if four parameters do not define
   * a Trapezoid with the top and bottom horizontal.
   */
  public Trapezoid( Pixel pt1, Pixel pt2, Pixel pt3, Pixel pt4 )
  {
     super( pt1, pt2, pt3, pt4 );	// Call constructor for Quadrilateral

     // Check to see if top and bottom are horizontal
 
     if ( pt1.y != pt2.y )
     {
        throw new IllegalArgumentException("Trapezoid: pixels pt1, pt2, "
               + "pt3, pt4 = " + pt1 +", " + pt2 + ", " + pt3 + ", " + pt4 
               + " do not form a trapezoid with top and bottom horizontal.");
     }

     if ( pt3.y != pt4.y )
     {
        throw new IllegalArgumentException("Trapezoid: pixels pt1, pt2, "
               + "pt3, pt4 = " + pt1 +", " + pt2 + ", " + pt3 + ", " + pt4 
               + " do not form a trapezoid with top and bottom horizontal.");
     }

   }

  // Note that paint() is inherited from Quadrilateral
}
