import java.awt.*; public class Point { private int x; private int y; // Constructs a point at the origin. public Point() { x = 0; y = 0; } // Constructs a point at an initial x and y value. public Point(int initialX, int initialY) { x = initialX; y = initialY; } // Returns the value of the x coordinate. public int getX() { return x; } // Returns the value of the y coordinate. public int getY() { return y; } // Draws a point using the given Graphics object. public void draw(Graphics g) { g.fillOval(x, y, 3, 3); g.drawString(toString(), x, y); } // Get the distance this point is from a second point. public double distance(Point point) { int dx = point.x - x; int dy = point.y - y; double distance = Math.sqrt(dx * dx + dy * dy); return distance; } // Returns the distance this point is from the origin. public double distanceFromOrigin() { Point p = new Point(); double dist = distance(p); return dist; } // Sets the point at a new location. public void setLocation(int newX, int newY) { x = newX; y = newY; } // Returns a string representation of the Point. public String toString() { return "(" + x + ", " + y + ")"; } // Moves a point by a given x, y amount. public void translate(int dx, int dy) { setLocation(x + dx, y + dy); } }