package sg;

/**
 * Creates an object representing a rectangle.
 * The rectangle 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 top and bottom with end points (p1,p2) and (p3,p4) of
 * the parallelogram are assumed to be horizontal and the sides are assumed
 * vertical.
 */
public class Rectangle extends Parallelogram
{
   /**
    * Four-parameter constructor.  Parallelogram constructor assures
    * that top and bottom are parallel and this constructor does the
    * same for the sides.
    */
   public Rectangle( Pixel pt1, Pixel pt2, Pixel pt3, Pixel pt4 )
   {
       super( pt1,pt2,pt3,pt4 );
       // Check to make sure that sides are vertical
       if ( pt1.y != pt4.y || pt2.y != pt3.y )
          throw new IllegalArgumentException("Rectangle: pixels pt1, pt2, "
              + "pt3, pt4 = " + pt1 +", " + pt2 + ", " + pt3 + ", " + pt4 
              + " do not form a rectangle with sides vertical.");
   }
}
