class GRectangle| Constructor | |
| GRectangle() GRectangle(x, y, width, height) | Creates a GRectangle object with the specified components. |
| Methods | |
| getX() | Returns the x component of the rectangle. |
| getY() | Returns the y component of the rectangle. |
| getWidth() | Returns the width component of the rectangle. |
| getHeight() | Returns the height component of the rectangle. |
| isEmpty() | Returns true if the rectangle is empty. |
| contains(pt) contains(x, y) | Returns true if the rectangle contains the given point, which may be specified either as a point or as distinct coordinates. |
| toString() | Converts the GRectangle to a string in the form "(x, y, width, height)". |
GRectangle(); GRectangle(double x, double y, double width, double height);
GRectangle object with the specified components.
If these parameters are not supplied, the default constructor sets
these fields to 0.
Usage:
GRectangle empty; GRectangle r(x, y, width, height);
double getX();
Usage:
double x = r.getX();
double getY();
Usage:
double y = pt.getY();
double getWidth();
Usage:
double width = r.getWidth();
double getHeight();
Usage:
double height = pt.getHeight();
bool isEmpty();
true if the rectangle is empty.
Usage:
if (r.isEmpty()) . . .
bool contains(GPoint pt); bool contains(double x, double y);
true if the rectangle contains the given point,
which may be specified either as a point or as distinct coordinates.
Usage:
if (r.contains(pt)) . . . if (r.contains(x, y)) . . .
string toString();
GRectangle to a string in the form
"(x, y,
width, height)".
Usage:
string str = r.toString();