previous | start | next

File AccountTest.java

1 /**
2     This program tests the BankAccount class and
3     their subclasses. 
4 */
5  public class AccountTest
6 {  
7    public static void main(String[] args)
8    {  
9       SavingsAccount momsSavings 
10          = new SavingsAccount(0.5);
11          
12       CheckingAccount harrysChecking
13          = new CheckingAccount(100);
14          
15       momsSavings.deposit(10000);
16       
17       momsSavings.transfer(harrysChecking, 2000);     
18       harrysChecking.withdraw(1500);
19       harrysChecking.withdraw(80);      
20
21       momsSavings.transfer(harrysChecking, 1000);
22       harrysChecking.withdraw(400);      
23
24       // simulate end of month
25       momsSavings.addInterest();
26       harrysChecking.deductFees();
27       
28       System.out.println("Mom's savings balance = $"
29          + momsSavings.getBalance());
30
31       System.out.println("Harry's checking balance = $"
32          + harrysChecking.getBalance());
33    }
34 }


previous | start | next