// CSE 142, Autumn 2010, Marty Stepp // This client program uses the BankAccount class. // Today's version uses the constructor and encapsulation that we wrote. public class Bank { public static void main(String[] args) { BankAccount marty = new BankAccount("Marty"); BankAccount jessica = new BankAccount("Jessica"); marty.deposit(5.00); jessica.deposit(12345.00); System.out.println(marty); System.out.println(jessica); marty.withdraw(2.25); marty.withdraw(100.00); marty.withdraw(-1.00); // can't do this any more because BankAccount is encapsulated // marty.balance = -9999.99; // marty.balance = marty.balance - 2.25; jessica.withdraw(50.00); System.out.println(marty.getBalance()); System.out.println(jessica.getBalance()); // these do not work! BankAccount is encapsulated // double b = marty.getBalance(); // b = 100000000; // marty.getBalance() = 10000000; // compute the total money stored in this bank double totalMoney = marty.getBalance() + jessica.getBalance(); System.out.println("Total money: $" + totalMoney); } }