public final class Rectangle extends Shape
Constructor and Description |
---|
Rectangle()
Constructor passes default values of all zeros to
Rectangle(int, int, int, int) constructor.
|
Rectangle(int x,
int y,
int length,
int width)
Constructor sets length and width of the rectangle and passes the point
where it will draw to the Shape superclass constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
draw()
Prints the length and width of the rectangle to the terminal window.
|
int |
getLength()
Returns the length of the rectangle.
|
int |
getWidth()
Returns the width of the rectangle.
|
void |
setLength(int length)
Sets the length of the rectangle which must be greater than zero (0)
or equal to zero if null (default).
|
void |
setWidth(int width)
Sets the width of the rectangle which must be greater than zero (0)
or equal to zero if null (default).
|
public Rectangle()
public Rectangle(int x, int y, int length, int width)
x
- the x-coordinate where the shape drawsy
- the y-coordinate where the shape drawslength
- the length of the rectanglewidth
- the width of the rectanglepublic void setLength(int length)
length
- the radius of the rectanglepublic void setWidth(int width)
width
- the radius of the rectanglepublic int getLength()
public int getWidth()