// Second version of Point class for storing an ordered pair (x, y). This // version has fields, a method that changes the state of the object // (translate), and a method that just examines the state of the object // (distanceFromOrigin). 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 origin (0, 0) public double distanceFromOrigin() { return Math.sqrt(x * x + y * y); } }