Solution to the distance formula within a Point class
public class Point {
private double x;
private double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() { return x; }
public double getY() { return y; }
public double square(double x) { return x * x; }
public double distance(Point otherPoint) {
return Math.sqrt(square(x - otherPoint.getX()) + square(y - otherPoint.getY()));
}
public String toString() {
return "(" + x + ", " + y + ")";
}
}