|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectPoint
public class Point
A Point object represents a 2-D (x, y) pair in the Cartesian plane.
| Constructor Summary | |
|---|---|
Point()
Constructs a new point object at the origin, (0, 0). |
|
Point(int x,
int y)
Constructs a new point with the given x/y coordinates. |
|
| Method Summary | |
|---|---|
Point |
clone()
Creates a copy of this Point object. |
double |
distance(Point p)
Returns the direct distance between this point and the given other point. |
boolean |
equals(java.lang.Object o)
Returns whether o refers to a Point object with the same x/y coordinates as this Point. |
int |
getX()
Returns the x-coordinate of this point. |
int |
getY()
Returns the y-coordinate of this point. |
java.lang.String |
toString()
Returns a string representation of this point, such as "(3, -2)". |
void |
translate(int dx,
int dy)
Shifts the x/y position of this point by the given offsets. |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Point()
public Point(int x,
int y)
x - the x-coordinate to usey - the x-coordinate to use| Method Detail |
|---|
public Point clone()
clone in class java.lang.Objectpublic double distance(Point p)
p - the point to measure against
java.lang.NullPointerException - if p is nullpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to compare against
public int getX()
public int getY()
public void translate(int dx,
int dy)
dx - the x-offset by which to shiftdy - the y-offset by which to shiftpublic java.lang.String toString()
"(3, -2)".
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||