// Class to represent a simple cartesian point value and do computations between this and another point public class Point { private int x, y; // x, y, coordinate public Point() // 0-arg constructor, we don't know where the Point is so use the origin { x = y = 0; } public Point(int newX, int newY) // 2-arg constructor { x = newX; y = newY; } public int getX() // accessors { return x; } public int getY() { return y; } public void setX(int newX) // mutators { x = newX; } public void setY(int newY) { y = newY; } public double distance(Point p2) // compute and return the distance between this Point and p2 { return Math.sqrt(Math.pow(x-p2.getX(),2) + Math.pow(y-p2.getY(),2)); } public String getLocation() // determine which quadrant this Point is in or if it is on either axis or the origin { if(x>0&&y>0) return "NE"; else if(x>0&&y<0) return "SE"; else if(y<0&&x<0) return "SW"; else if(x<0&&y>0) return "NW"; else if(x==0&&y==0) return "Origin"; else if(x==0) return "On Y"; else return "On X"; } public String toString() // return the Point as a String using notation { return "<" + x + ", " + y + ">"; } }