package sg;

/**
 * Creates a square object.
 */
public class Square extends Rectangle
{
   /**
    * Four parameter constructor insures that new object is a square.
    * If not, throws IllegalArgumentException.
    */
   public Square( Pixel pt1, Pixel pt2, Pixel pt3, Pixel pt4 )
   {
       super( pt1,pt2,pt3,pt4 );	// Ensures rectangle
       if ( (pt2.x - pt1.x) != (pt3.y - pt2.y) ||
            (pt3.y - pt2.y) != (pt3.x - pt4.x) ||
            (pt3.x - pt4.x) != (pt4.y - pt1.y) )
          throw new IllegalArgumentException("Square: pixels pt1, pt2, "
              + "pt3, pt4 = " + pt1 +", " + pt2 + ", " + pt3 + ", " + pt4 
              + " do not form a square - sides not same length.");
   }
}

