m865.shapepack
Class Square

java.lang.Object
  extended by m865.shapepack.Shape
      extended by m865.shapepack.Rectangle
          extended by m865.shapepack.Square

public class Square
extends Rectangle

The Square subclass of Rectangle.


Field Summary
 
Fields inherited from class m865.shapepack.Shape
color, defaultColor, defaultHeight, defaultWidth, height, width, x, y
 
Constructor Summary
Square(int x, int y)
          Constructor for a square at the specified location with the default width (and height) and color.
Square(int x, int y, int w, java.awt.Color c)
          The generic Square constructor.
 
Method Summary
 void setHeight(int h)
          Set the height of the square.
 void setWidth(int w)
          Set the width of the square.
 java.lang.String toString()
          Generates the string describing the rectangle.
 
Methods inherited from class m865.shapepack.Rectangle
area, draw, perimeter
 
Methods inherited from class m865.shapepack.Shape
getColor, getHeight, getWidth, getX, getY, moveTo, setColor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Square

public Square(int x,
              int y,
              int w,
              java.awt.Color c)
The generic Square constructor.

Parameters:
x - horizontal coordinate of the upper left corner of the square.
y - vertical coordinate of the upper left corner of the square.
w - width (and height) of the square.
c - fill color for the rectangle.

Square

public Square(int x,
              int y)
Constructor for a square at the specified location with the default width (and height) and color.

Parameters:
x - horizontal coordinate of the upper left corner of the square.
y - vertical coordinate of the upper left corner of the square.
Method Detail

setWidth

public void setWidth(int w)
Set the width of the square.

Overrides:
setWidth in class Shape
Parameters:
w - the new width (and height) of the square.

setHeight

public void setHeight(int h)
Set the height of the square.

Overrides:
setHeight in class Shape
Parameters:
h - the new height (and width) of the square.

toString

public java.lang.String toString()
Description copied from class: Rectangle
Generates the string describing the rectangle.

Overrides:
toString in class Rectangle