// A test Applet to show how to use the AccountException class. // This applet catches an exception thrown by the other class. // Nancy McCracken 5/14/97 import java.awt.*; public class AccountExceptionTest extends java.applet.Applet { Font f = new Font("TimesRoman", Font.BOLD, 24); AccountException kathy; // variable for instance of Account class int x; // variables x and y control print placement int y; public void init() { // create a new instance of the Account class kathy = new AccountException ("Kathy", 100.F ); } public void paint(Graphics g) { String s; g.setFont(f); x = 25; y = 25; print(g, "Kathy's initial balance is $" + kathy.getbalance()); try { kathy.withdraw(523.F); print(g, "Kathy tries to withdraw $523."); } catch(Exception e) {print(g, e.getMessage());} kathy.deposit(1500.F); print(g, "Kathy deposits $1500."); kathy.monthactivity(); print(g, "After one month, Kathy's account has $" + kathy.getbalance()); } public void print(Graphics g, String s) { g.drawString (s, x, y); y += 30; } }