1  // A simple Applet to show how to use the Account class
  2  //       Nancy McCracken 3/14/97
  3  
  4  import java.awt.*;
  5  
  6  public class AccountTest extends java.applet.Applet
  7  { Font f = new Font("TimesRoman", Font.BOLD, 24);
  8  
  9    Account george;    // variable for instance of Account class
 10    int x;             // variables x and y control print placement
 11    int y;
 12  
 13    public void init()
 14    {
 15      // create a new instance of the Account class
 16      george = new Account ("George", 5000.F );
 17    }
 18  
 19    public void paint(Graphics g)
 20    { String s;
 21      g.setFont(f);
 22      x = 25; y = 25;
 23      print(g, "George's initial balance is $" 
 24                   + george.getbalance());
 25  
 26      // call an Account method on the instance george
 27      george.deposit(1500.F);
 28      print(g, "George deposits $1500.");
 29  
 30      s = george.withdraw(523.F);
 31      print(g, "George withdraws $523.");
 32  
 33      george.monthactivity();
 34      print(g, "After one month, George's account has $"
 35  	       + george.getbalance());
 36    }
 37  
 38    public void print(Graphics g, String s)
 39    { g.drawString (s, x, y);
 40      y += 30;
 41    }
 42  }