// Helene Martin, CSE 142 // Client that uses our custom Point class. // Point.java must be in the same folder. public class PointMain { public static void main(String[] args){ Point p1 = new Point(); Point p2 = new Point(); p1.x = 23; p2.x = 45; p1.y = 34; p2.y = 567; System.out.println("(" + p1.x + ", " + p1.y + ")"); System.out.println("(" + p2.x + ", " + p2.y + ")"); // translation p1.x += 4; p1.y += 6; System.out.println("(" + p1.x + ", " + p1.y + ")"); System.out.println("(" + p2.x + ", " + p2.y + ")"); // better translation, calling instance method p1.translate(4, 6); System.out.println("(" + p1.x + ", " + p1.y + ")"); System.out.println("(" + p2.x + ", " + p2.y + ")"); } /* We could write a static method for translating points. Note that this code would have to be included in each client that wants points to be translated. Putting it in the Point class as an instance method means that this code doesn't need to be repeated! public static void translate(Point p1, int dx, int dy) { p1.x += dx; p1.y += dy; } */ }