// This program demonstrates the usage of Point objects. // This is an example of "Client code" -- code that uses objects. public class PointMain { public static void main(String[] args) { // create two Point objects Point p1 = new Point(); p1.setLocation(7, 2); Point p2 = new Point(); p2.setLocation(4, 3); // print each point and its distance from the origin (0, 0) System.out.println("p1 is (" + p1.x + ", " + p1.y + ")"); System.out.println("p1's distance from origin = " + p1.distanceFromOrigin()); System.out.println("p2 is (" + p2.x + ", " + p2.y + ")"); System.out.println("p2's distance from origin = " + p2.distanceFromOrigin()); // move points and then print them again p1.translate(11, 6); p2.translate(1, 7); System.out.println("p1 is (" + p1.x + ", " + p1.y + ")"); System.out.println("p2 is (" + p2.x + ", " + p2.y + ")"); // compute distance between two points double dist = p1.distance(p2); System.out.println("p1 is " + dist + " away from p2."); } }