
class Rectangle extends Polygon
{
   // Instance variables

   private Point upperLeft;	// Upper left corner of rectangle
   private int height, width;

   public Rectangle()		// 0-param constructor
   { this( new Point(0,0), 1, 1 ); }	// Default values

   public Rectangle( Point ul, int h, int w) // 3-param constructor
   {
       upperLeft = new Point();
       upperLeft.x = ul.x;  upperLeft.y = ul.y;
       height = h; width = w;
   }

   public void paint( Graphics g )
   {
      g.drawLine(upperLeft.x, upperLeft.y,
                 upperLeft.x+width, upperLeft.y);
      g.drawLine(upperLeft.x+width, upperLeft.y,
                 upperLeft.x+width, upperLeft.y+height);
      g.drawLine(upperLeft.x+width, upperLeft.y+height,
                 upperLeft.x, upperLeft.y+height);
      g.drawLine(upperLeft.x, upperLeft.y+height,
                 upperLeft.x, upperLeft.y);
   }
}
