// This client program constructs three points by calling constructors, // translates two of the points, prints them, and then reports the distance // between two of them. public class PointClient3 { public static void main(String[] args) { // construct a point p1 with coordinates (3, 5) // construct a point p2 with (12, 4) // construct a point p3 with (0, 0) Point p1 = new Point(3, 5); Point p2 = new Point(12, 4); Point p3 = new Point(); // print all 3 points System.out.println("p1 = " + p1); System.out.println("p2 = " + p2); System.out.println("p3 = " + p3); // translate p1 by (-1, -2) // translate p2 by (6, 8) p1.translate(-1, -2); p2.translate(6, 8); // print p1, p2, p3 System.out.println("p1 = " + p1); System.out.println("p2 = " + p2); System.out.println("p3 = " + p3); // print p1 distance to origin // print p2 distance to origin System.out.println("p1 distance = " + p1.distanceFromOrigin()); System.out.println("p2 distance = " + p2.distanceFromOrigin()); // print sum of p1 coordinates int sum = p1.getX() + p1.getY(); System.out.println("sum of p1 coordinates = " + sum); } }