// Helene Martin, CSE 142 // Blueprint for creating objects of type Point public class Point { int x; int y; public Point(int initialX, int initialY) { x = initialX; y = initialY; } public Point() { x = 0; y = 0; } // mutator // moves x and y coordinates of this point by specified amount public void translate(int dx, int dy) { x += dx; y += dy; } /* public void setLocation(int x, int y) { this.x = x; this.y = y; }*/ public void setLocation(int newX, int newY) { x = newX; y = newY; } // accessor // returns the distance of this Point from the origin public double distanceFromOrigin() { return Math.sqrt(x * x + y * y); } public double distance(Point other) { int dx = x - other.x; int dy = y - other.y; return Math.sqrt(dx * dx + dy * dy); } public String toString() { return "(" + x + ", " + y + ")"; } }