// Second version of Point class for storing an ordered pair (x, y). This // version has fields, an accessor method (distance) and a mutator method // (translate). public class Point { int x; int y; // translates this point's coordinates by the given delta-x and delta-y public void translate(int dx, int dy) { x = x + dx; y = y + dy; } // returns the distance from this point to the given point public double distance(Point other) { int dx = this.x - other.x; int dy = this.y - other.y; return Math.sqrt(dx * dx + dy * dy); } }