import java.util.*;

public class TestBankAccount {

	public static void main(String[] args) {

		// Create 5 different bank accounts.
		BankAccount[] accts = new BankAccount[5];
		accts[0] = new BankAccount();
		accts[1] = new BankAccount(1000);
		accts[2] = new SavingsAccount();
		accts[3] = new SavingsAccount(5000,.03);
		accts[4] = new CheckingAccount(2000);

		// Print to make sure they start okay.
		for (BankAccount b : accts)
			System.out.println(b);

		// Show penalty system for Checking accounts.
		accts[4].withdraw(1900);
		System.out.println(accts[4]);
		accts[4].withdraw(51);
		System.out.println(accts[4]);

		// Show no penalty (and the way they coded it, you can do negative balance here also!) for reg Bank Account.
		accts[1].withdraw(900);
		System.out.println(accts[1]);
		accts[1].withdraw(101);
		System.out.println(accts[1]);

		// Show use of default interest rate.
		accts[2].deposit(800);
		System.out.println(accts[2]);
		((SavingsAccount)accts[2]).addInterest();
		System.out.println(accts[2]);

		// Show that this account has a better interest rate applied!
		((SavingsAccount)accts[3]).addInterest();
		System.out.println(accts[3]);

		// Final test - add 300 to each, then add interest if a savings account, then withdraw 200, then print.
		for (int i=0; i<accts.length; i++) {

			// Add 300 then add interest if it applies.
			accts[i].deposit(300);
			if (accts[i] instanceof SavingsAccount)
				((SavingsAccount)accts[i]).addInterest();

			// Take out 200 and print.
			accts[i].withdraw(200);
			System.out.println(accts[i]);

			// Take out 100 more and print (tests Fee for Checking account again...)
			accts[i].withdraw(100);
			System.out.println(accts[i]);
		}

	}
}