/** This Class is a coordinate with x and y. */ public class Point { public double x,y; /** Default constructor with x=0 and y=0 */ public Point () { x=0; y=0; } /** Constructor sets x and y */ public Point (double x, double y) { this.x=x; this.y=y; } /** Copy Constructor */ public Point (Point p) { this.x=p.x; this.y=p.y; } /** Converts the coordiante to a String for printing */ public String toString() { return("Point ("+x+","+y+")"); } /** Calculates the distance to another Point */ public double distance(Point p2) { return (Math.sqrt( (x-p2.x)*(x-p2.x) + (y-p2.y)*(y-p2.y) )); } /** Returns the position as a Point (in this case it returns itself) */ public Point position() { return this; } }