Class Rectangle
java.lang.Object
|
+--Subject
|
+--Shape
|
+--Rectangle
- public class Rectangle
- extends Shape
A Square is a Shape. Squares have all methods and attributes of Shape
and then some more.
Constructor Summary |
Rectangle()
Initialize a green Rectangle with width 10, height 20, position 100,100 |
Rectangle(java.awt.Color c,
int width,
int height,
int x,
int y)
Initialize a new Rectangle with specified Color, width, height and position |
Method Summary |
void |
display(java.awt.Graphics g)
produce a graphical representation of this |
int |
getHeight()
|
int |
getWidth()
|
void |
setHeight(int h)
Set the height of this, tell our observer that we have changed |
void |
setWidth(int w)
Set the width of this, tell our observer that we have changed |
java.lang.String |
toString()
|
Methods inherited from class Subject |
attachObserver,
detachObserver,
notifyObserver |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Rectangle
public Rectangle()
- Initialize a green Rectangle with width 10, height 20, position 100,100
Rectangle
public Rectangle(java.awt.Color c,
int width,
int height,
int x,
int y)
- Initialize a new Rectangle with specified Color, width, height and position
- Parameters:
c
- the desired colorwidth
- the desired widthheight
- the desired heightx
- the desired x coordinatey
- the desired x coordinate
setWidth
public void setWidth(int w)
- Set the width of this, tell our observer that we have changed
- Parameters:
w
- the desired width- Returns:
- nothing
setHeight
public void setHeight(int h)
- Set the height of this, tell our observer that we have changed
- Parameters:
h
- the desired height- Returns:
- nothing
getWidth
public int getWidth()
- Returns:
- the width of this
getHeight
public int getHeight()
- Returns:
- the height of this
toString
public java.lang.String toString()
- Returns:
- a String representation of this
- Overrides:
- toString in class Shape
display
public void display(java.awt.Graphics g)
- produce a graphical representation of this
- Parameters:
g
- the pen we use to display this- Overrides:
- display in class Shape