public final class IPoint2D extends Object
IPoint2D as an x and a y
coordinate.| Constructor and Description |
|---|
IPoint2D()
Constructs a point with coordinates
(0.0, 0.0). |
IPoint2D(double x,
double y)
Constructs a point with coordinates
(x, y). |
| Modifier and Type | Method and Description |
|---|---|
double |
distanceTo(IPoint2D other)
Returns the distance between
this point and another
point. |
boolean |
equals(Object obj)
Compares this point to another object.
|
double |
getX()
Returns the
x coordinate of this point. |
double |
getY()
Returns the
y coordinate of this point. |
String |
toString()
Returns a string containing the coordinates of the point separated by
a space and a comma and inside round brackets.
|
public IPoint2D()
(0.0, 0.0).public IPoint2D(double x,
double y)
(x, y).x - the x coordinatey - the y coordinatepublic double getX()
x coordinate of this point.x coordinate of this pointpublic double getY()
y coordinate of this point.y coordinate of this pointpublic double distanceTo(IPoint2D other)
this point and another
point.other - the point to compute the distance tothis point and otherpublic boolean equals(Object obj)
true
if and only if the argument is not null and is an
IPoint2 object that has the same coordinates of
this object.equals in class ObjectObject.equals(java.lang.Object)obj - the other object to comparetrue if obj is an IPoint2
object with the same coordinates as this objectpublic String toString()
(new IPoint2(-1.5, 3.1415)).toString()
returns the string "(-1.5, 3.1415)".toString in class ObjectObject.toString()