import static java.lang.Math.sqrt;
class Point {
public Point(double xVal, double yVal) {
x = xVal;
y = yVal;
}
public Point(final Point aPoint) {
x = aPoint.x;
y = aPoint.y;
}
public void move(double xDelta, double yDelta) {
x += xDelta;
y += yDelta;
}
public double distance(final Point aPoint) {
return sqrt((x - aPoint.x) * (x - aPoint.x) + (y - aPoint.y) * (y - aPoint.y));
}
public String toString() {
return Double.toString(x) + ", " + y;
}
private double x;
private double y;
}
|