// AccountTest.java // Solution to Short Assignment 11 by THC. // Modifies the AccountTest.java program from lecture, substituting an // ATMSavingsAccount for a Checking Account. public class AccountTest { public static void main(String[] args) { SavingsAccount momsSavings = new SavingsAccount(0.5); TimeDepositAccount collegeFund = new TimeDepositAccount(1.0, 10000.00, 3, 0.5); ATMSavingsAccount harrysSavings = new ATMSavingsAccount(5.0); momsSavings.deposit(10000.00); momsSavings.transfer(harrysSavings, 2000); harrysSavings.withdraw(200); harrysSavings.withdraw(300); harrysSavings.withdraw(80); harrysSavings.withdraw(400); endOfMonth(momsSavings); endOfMonth(collegeFund); endOfMonth(harrysSavings); collegeFund.transfer(harrysSavings, 980); System.out.println("Mom's savings. " + momsSavings); // (10000 - 2000) * .5 % interest = 8040 System.out.println("The college fund. " + collegeFund); // (10000 * 1% interest) * 0.5% penalty - 980 = 9069.50 System.out.println("Harry's ATM savings. " + harrysSavings); // (2000 - 200 - 300 - 80 - 400) * 5% interest - 2 withdrawal fees + 980 // = 2048 } // Handles end-of-month operations. Overloaded function, because // checking account does different things than savings account. public static void endOfMonth(SavingsAccount savings) { savings.addPeriodicInterest(); } public static void endOfMonth(CheckingAccount checking) { checking.deductFees(); } }