public class Rectangle extends Shape implements Comparable<Rectangle>
Constructor and Description |
---|
Rectangle()
Initializes the width and height of this rectangle to zero.
|
Rectangle(int width,
int height)
Initializes this rectangle with the given width and height.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Rectangle other)
Compares this rectangle with the given rectangle.
|
boolean |
equals(Object other)
Tests if this rectangle is the same as the given object, that is,
the object is an instance of this class and has the same width and
height as this rectangle.
|
double |
getArea()
Returns the area of this rectangle.
|
int |
getHeight()
Returns the height of this rectangle.
|
static Rectangle |
getRandom()
Returns a random rectangle.
|
int |
getWidth()
Returns the width of this rectangle.
|
String |
toString()
Returns a string representation of this rectangle.
|
public Rectangle(int width, int height)
width
- The width of this rectangle.height
- The height of this rectangle.public Rectangle()
public static Rectangle getRandom()
public int getWidth()
public int getHeight()
public double getArea()
public String toString()
public boolean equals(Object other)
public int compareTo(Rectangle other)
compareTo
in interface Comparable<Rectangle>
other
- another rectangle.