csa120.shape
Class Square
java.lang.Object
csa120.shape.Shape
csa120.shape.FillableShape
csa120.shape.Rectangle
csa120.shape.Square
- All Implemented Interfaces:
- Drawable, FillableShapeOrGroup, ShapeOrGroup
- public class Square
- extends Rectangle
A Square is a subclass of Rectangle. To ensure that the
height and width remain the same, any change to one of those values
will automatically force a change of the other.
|
Constructor Summary |
Square(int s)
Constructor for objects of class Square |
|
Method Summary |
void |
setHeight(int newHeight)
This overrides the method in parent Rectangle to ensure
that the width and height remain equal. |
void |
setWidth(int newWidth)
This overrides the method in parent Rectangle to ensure
that the width and height remain equal. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Square
public Square(int s)
- Constructor for objects of class Square
- Parameters:
s - length of sides
setWidth
public void setWidth(int newWidth)
- This overrides the method in parent
Rectangle to ensure
that the width and height remain equal. A change to the width
of a Square, changes the height as well.
- Overrides:
setWidth in class Rectangle
- Parameters:
newWidth - the new value
setHeight
public void setHeight(int newHeight)
- This overrides the method in parent
Rectangle to ensure
that the width and height remain equal. A change to the height
of a Square, changes the width as well.
- Overrides:
setHeight in class Rectangle
- Parameters:
newHeight - the new value