|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.shapepack.Shape
m865.shapepack.Rectangle
The concrete Shape subclass that defines rectangles.
Field Summary |
Fields inherited from class m865.shapepack.Shape |
color, defaultColor, defaultHeight, defaultWidth, height, width, x, y |
Constructor Summary | |
Rectangle(int x,
int y)
Constructor for a rectangle at the specified location with the default width, height, and color. |
|
Rectangle(int x,
int y,
int w,
int h,
java.awt.Color c)
The generic Rectangle constructor |
Method Summary | |
float |
area()
Calculates the area. |
void |
draw(java.awt.Graphics g)
Draws the rectangle |
float |
perimeter()
Calculates the perimeter. |
java.lang.String |
toString()
Generates the string describing the rectangle. |
Methods inherited from class m865.shapepack.Shape |
getColor, getHeight, getWidth, getX, getY, moveTo, setColor, setHeight, setWidth |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Rectangle(int x, int y, int w, int h, java.awt.Color c)
x
- horizontal coordinate of the upper left corner of the rectangle.y
- vertical coordinate of the upper left corner of the rectangle.w
- width of the rectangle.h
- height of the rectangle.c
- fill color for the rectangle.public Rectangle(int x, int y)
x
- horizontal coordinate of the upper left corner of the rectangle.y
- vertical coordinate of the upper left corner of the rectangle.Method Detail |
public void draw(java.awt.Graphics g)
draw
in class Shape
g
- the graphics object on which the shape is to be drawn.public float area()
area
in class Shape
public float perimeter()
perimeter
in class Shape
public java.lang.String toString()
toString
in class Shape
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |