// This file defines a new class of objects named Point. public class Point { // The following contents exist inside each Point object. private int x; // Each Point has an x and y that can be private int y; // seen by all of the methods below. public Point() { // x = 0; // y = 0; setLocation(0, 0); } // Constructs a new Point object at the given coordinates. public Point(int initialX, int initialY) { x = initialX; y = initialY; //setLocation(initialX, initialY); } public int getX() { return x; } public int getY() { return y; } // Shifts the point's position by the given amounts. public void translate(int dx, int dy) { setLocation(x + dx, y + dy); // x += dx; // y += dy; } // Computes the distance between this point and the given other point. public double distance(Point otherPoint) { int dx = x - otherPoint.x; int dy = y - otherPoint.y; return Math.sqrt(dx * dx + dy * dy); } // Computes the distance between this point and the origin, (0, 0). public double distanceFromOrigin() { return Math.sqrt(x * x + y * y); // return distance(new Point(0, 0)); } public void setLocation(int newX, int newY) { x = newX; y = newY; } }