
package sg;

/**
 * Creates an object representing a parallelogram.
 * The parallelogram 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.
 *
 * For simplicity, the two sides with end points (p1,p2) and (p3,p4) of
 * the parallelogram are assumed to be horizontal.
 */
 
public class Parallelogram extends Trapezoid
{

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

     // Check to see if sides are parallel
    
     Line leftSide = new Line(pt4,pt1);
     Line rightSide = new Line(pt3,pt2);
     if ( !leftSide.isParallel( rightSide ) )
     {
        throw new IllegalArgumentException("Parallelogram: pixels pt1, pt2, "
              + "pt3, pt4 = " + pt1 +", " + pt2 + ", " + pt3 + ", " + pt4 
              + " do not form a parallelogram with top and bottom horizontal.");
     }
 
   }

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