// Marty Stepp, CSE 142, Autumn 2009 // A short "client" program that uses our Point objects. // This third version uses our new Point constructors and toString method. import java.awt.*; public class Example { public static void main(String[] args) { Point p1 = new Point(81, 131); Point p2 = new Point(52, 202); Point p3 = new Point(); p1.translate(5, -10); p2.translate(100, 100); double d = p1.distance(p2); double d2 = p2.distance(p1); System.out.println("p1 x = " + p1.x + ", y = " + p1.y); System.out.println("p2 x = " + p2.x + ", y = " + p2.y); System.out.println("p1 is " + p1); System.out.println("distance = " + d); System.out.println("distance 2 = " + d2); DrawingPanel panel = new DrawingPanel(300, 300); Graphics g = panel.getGraphics(); p1.setLocation(-5, 17); p1.draw(g); p2.draw(g); // demonstrate the usage of the BankAccount class BankAccount marty = new BankAccount(); // I cannot directly access the balance field because it is private; // marty.balance = 10000000; // error System.out.println(marty.getBalance()); marty.deposit(50); // this deposit fails System.out.println(marty.getBalance()); marty.deposit(1000000); System.out.println(marty.getBalance()); marty.deposit(78); System.out.println(marty.getBalance()); } }