// CSE 142, Autumn 2010, Marty Stepp // This "client" program uses our Point class. // Today's version uses the constructor and encapsulation that we wrote. import java.awt.*; // for Graphics public class PointClient { public static void main(String[] args) { // create two Point objects Point p1 = new Point(51, 21); // calls the constructor Point p2 = new Point(182, 12); Point p3 = new Point(); // origin, (0, 0) System.out.println(p1.distance(p2)); // uses the toString method System.out.println("p1 is " + p1); System.out.println("p2 is " + p2); // move p2 and then print it // p2.x += 2; // can't set x/y directly; encapsulated // p2.y++; p2.translate(2, 1); System.out.println("p1 is " + p1); System.out.println("p2 is " + p2); // 98, 52 // draw the two points on a DrawingPanel DrawingPanel panel = new DrawingPanel(200, 200); Graphics g = panel.getGraphics(); p1.draw(g); p2.draw(g); } }