public class Point extends Object
Point
class represents a two-dimensional location, constructed from (x,y)
coordinates with some methods for access and the capability to calculate the distance from
this point to another point.
Example usage:
Point a = new Point(3, 4); Point b = new Point(2, 5); double dist = a.distance(b);
This software is licensed with an Apache 2 license, see http://www.apache.org/licenses/LICENSE-2.0 for details.
Constructor and Description |
---|
Point(int startx,
int starty)
Create a
Point object from x and y coordinates. |
Modifier and Type | Method and Description |
---|---|
double |
distance(Point otherPt)
Calculate and return the Euclidean distance from this point to another point.
|
int |
getX()
Returns the x coordinate of this point.
|
int |
getY()
Returns the y coordinate of this point.
|
static void |
main(String[] args) |
String |
toString()
Returns a string representation of this point.
|
public Point(int startx, int starty)
Point
object from x and y coordinates.startx
- is the x-coordinatestarty
- is the y-coordinatepublic int getX()
public int getY()
public double distance(Point otherPt)
otherPt
- the other point to which distance is calculatedpublic String toString()
public static void main(String[] args)