csa120.shape
Class Square

java.lang.Object
  extended bycsa120.shape.Shape
      extended bycsa120.shape.FillableShape
          extended bycsa120.shape.Rectangle
              extended bycsa120.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.


Field Summary
 
Fields inherited from class csa120.shape.Rectangle
height, width
 
Fields inherited from class csa120.shape.FillableShape
fillColor, filled
 
Fields inherited from class csa120.shape.Shape
borderColor, borderThickness, depth, location
 
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 csa120.shape.Rectangle
draw, draw, getHeight, getWidth
 
Methods inherited from class csa120.shape.FillableShape
getFillColor, getFilled, setFillColor, setFillColor, setFilled
 
Methods inherited from class csa120.shape.Shape
getBorderColor, getBorderThickness, getDepth, getLocation, move, setBorderColor, setBorderColor, setBorderThickness, setDepth, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface csa120.shape.ShapeOrGroup
move, setBorderColor, setBorderColor, setBorderThickness, setDepth
 
Methods inherited from interface csa120.shape.Drawable
getDepth
 

Constructor Detail

Square

public Square(int s)
Constructor for objects of class Square

Parameters:
s - length of sides
Method Detail

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