public class Rectangle extends Object
Constructor and Description |
---|
Rectangle()
Initializes this rectangle with zero width and height.
|
Rectangle(int width,
int height)
Initializes this rectangle with the given width and height.
|
Rectangle(Rectangle rectangle)
Initializes this rectangle with the same width and height as the given rectangle.
|
Modifier and Type | Method and Description |
---|---|
int |
getArea()
Returns the area of this rectangle.
|
int |
getHeight()
Returns the height of this rectangle.
|
int |
getWidth()
Returns the width of this rectangle.
|
void |
scale(int factor)
Scales this rectangle with the given factor.
|
String |
toString()
Returns a string representation of this rectangle.
|
public Rectangle(int width, int height)
width
- width of this rectangle.height
- height of this rectangle.public Rectangle()
public Rectangle(Rectangle rectangle)
rectangle
- the rectangle to be copied.public int getWidth()
public int getHeight()
public int getArea()
public String toString()
public void scale(int factor)
factor
- the scaling factor.