import java.util.Scanner;

//***********************************************************
// TestBankAccounts1
// A simple program to test the numAccts method of the 
// BankAccount class.  
//***********************************************************
public class TestBankAccounts1
{
	BankAccount acct1,acct2,acct3,acct4,acct5,acct6;

	public TestBankAccounts1()
	{
		System.out.println("Creating bank accounts");
		acct1=new BankAccount(154.34, "Logan");
		acct2=new BankAccount(344, "Vlad");
		acct3=new BankAccount(30, "DJ");        
		acct4=new BankAccount(555, "Logan");                  

		printInfo();
	}	

	public void testTotalFunds()
	{
		pause();
		System.out.println("Testing Total Funds");

	}

	public void printInfo()
	{
		System.out.println(acct1);
		System.out.println(acct2);
		System.out.println(acct3);
		System.out.println(acct4);
		if (acct5!=null)
			System.out.println(acct5);
		if (acct6!=null)
			System.out.println(acct6);
		System.out.println("Total number of BankAccount is " + BankAccount.getNumOfAccounts());
		System.out.println("Total funds " + BankAccount.getTotalMoney());

	}

	public void testCloseAccount()
	{
		System.out.println("Attempting to close account 2");
		pause();
		acct2.close();                
		printInfo();    

	}	

	public void testTransfer()
	{
		acct6=new BankAccount(2253, "Courtney");                  
		System.out.println("Active accounts");
		pause();                
		System.out.println(acct3);
		System.out.println(acct5);
		System.out.println(acct6);       

		System.out.println();        
		System.out.println("Attempting transfer of $200 from acct3 to acct6");
		pause();             
		acct3.transfer(acct6,200);
		System.out.println(acct3);
		System.out.println(acct5);
		System.out.println(acct6); 

		System.out.println();        
		System.out.println("Attempting transfer of $200 from acct3 to acct6");
		pause();             
		BankAccount.transfer(acct3,acct6,200);
		System.out.println(acct3);
		System.out.println(acct5);
		System.out.println(acct6);   

	}		

	public void consolidate(){
		System.out.println("Attempting to consolidate accounts 1 and 4");
		pause();
		acct5=BankAccount.consolidate(acct1,acct4);  
		printInfo();         
	}


	public void pause()
	{
		System.out.println("Hit enter to continue:");
		Scanner scan=new Scanner (System.in);
		scan.nextLine();
	}

	public static void main(String args[])
	{
		TestBankAccounts1 t = new TestBankAccounts1();
		t.testTotalFunds();
		t.testCloseAccount();
		t.consolidate();
		t.testTransfer();
	}
}