edu.duke

## Class Point

• ```public class Point
extends Object```
The `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);
```

Author:
Duke Coursera Team
• ### Constructor Summary

Constructors
Constructor and Description
```Point(int startx, int starty)```
Create a `Point` object from x and y coordinates.
• ### Method Summary

All Methods
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.
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Constructor Detail

• #### Point

```public Point(int startx,
int starty)```
Create a `Point` object from x and y coordinates.
Parameters:
`startx` - is the x-coordinate
`starty` - is the y-coordinate
• ### Method Detail

• #### getX

`public int getX()`
Returns the x coordinate of this point.
Returns:
x coordinate
• #### getY

`public int getY()`
Returns the y coordinate of this point.
Returns:
y coordinate
• #### distance

`public double distance(Point otherPt)`
Calculate and return the Euclidean distance from this point to another point.
Parameters:
`otherPt` - the other point to which distance is calculated
Returns:
the distance from this point to otherPt
• #### toString

`public String toString()`
Returns a string representation of this point.
Overrides:
`toString` in class `Object`
Returns:
(x,y) for this point.
• #### main

`public static void main(String[] args)`