public class PA2Driver
{
    /**
	  *
	  * Driver for programming assignment #2
	  * @author Professor elizabeth Adams, James Madison University
	  *
	  */
  

  public static void main (String [] args)
  {
     SavingsAccount 				mySA;
	  FixedTermSavingsAccount  myFTSA0, myFTSA1;
	  MixedSavingsAccount		myMSA; 

  		String  tempString;
  		int     tempInt;
 		double  tempDouble;

  				// test account creation
  //1.
    myFTSA0 = new FixedTermSavingsAccount   ("adams");
    mySA 	= new SavingsAccount ("Smith");  
	 myFTSA1 = new FixedTermSavingsAccount   ("bernstein");
	 myMSA	= new MixedSavingsAccount ("Cushman", 250.0);

		// test two distinct FixedTermSavingsAccount IDs
    tempString =   myFTSA0.getAccountID();
    System.out.println (tempString + " expected: FT-0000000000");
	 

    tempString =   myFTSA1.getAccountID();
    System.out.println (tempString + " expected: FT-0000000002");

		// test a SavingsAccount ID
    tempString = mySA.getAccountID();
    System.out.println (tempString + " expected: SA-0000000001");  
	 
	   // test a MixedSavingsAccount ID
    tempString = myMSA.getAccountID();
	 System.out.println (tempString + " expected: MS-0000000003");

    	// test 2 FixedTermSavingsAccount user names
    System.out.println ();
    tempString =   myFTSA1.getUserName();
    System.out.println (tempString + " expected: bernstein@jmu.edu");
      
    tempString =   myFTSA0.getUserName();
    System.out.println (tempString + " expected: adams@jmu.edu");
    
			// test SavingsAccount user name
    tempString = 	 mySA.getUserName();    // calling parent's getUserName
    System.out.println (tempString + " expected: Smith@jmu.edu");

			// test MixedSavingsAccount user name
    tempString = 	 myMSA.getUserName();    // calling parent's getUserName
    System.out.println (tempString + " expected: Cushman@jmu.edu");

    System.out.println ("\n End Test 1 \n"); 

    //2. 
	 		// test getting initial balances
	 System.out.println (" testing initial balances ");	 
    tempDouble = myFTSA0.getBalance();
	 System.out.println (tempDouble + " expected:  0.0 ");
	
	 tempDouble = myFTSA1.getBalance();
	 System.out.println (tempDouble + " expected:  0.0 ");
	 
	 tempDouble = mySA.getBalance();
	 System.out.println (tempDouble + " expected:  0.0 ");

	 tempDouble = myMSA.getBalance();
    System.out.println (tempDouble + " expected:  0.0 ");

    System.out.println ("\n End Test 2 \n"); 

        // test getting initial balance messages
    //3. 
	 System.out.println (" testing initial balance messages ");	  
	 tempString = myFTSA0.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected:   Balance: $.00");
 
	 tempString = myFTSA1.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected:  Balance:   $.00");
 
	 tempString = mySA.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected:  Balance:   $.00");
 
	 tempString = myMSA.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: Total Balance: $0.00" +
	 		" Available Balance: $0.00 Unavailable Balance: $0.00");
 
     System.out.println ("\n End Test 3 \n"); 
 
                  // test compareTo method
    //4.
    tempInt =   myFTSA0.compareTo(  myFTSA1);  
    System.out.println (tempInt + " expected:  -1" );

    tempInt =   myFTSA1.compareTo (myFTSA0);
	 System.out.println (tempInt + " expected:  1");

    tempInt = myFTSA1.compareTo (myFTSA1);
	 System.out.println (tempInt + " expected:  0");

    tempInt = myFTSA1.compareTo(mySA);
	 System.out.println (tempInt + " expected 1 ");

	 tempInt = myMSA.compareTo(mySA);
	 System.out.println (tempInt + " expected 1 ");

    System.out.println ("\n End Test 4 \n"); 

			// test deposit methode
   //5.
    tempString =   myFTSA1.deposit(12345.6462);
    System.out.println ("Actual:   "    + tempString );
    System.out.println ("Expected: "   + 12345.6462 + " deposited ");
    
    tempString =   myFTSA0.deposit(365.65);
    System.out.println ("Actual:   "    + tempString  );
    System.out.println ("Expected: "  + 365.65 + " deposited ");
 
	 tempString =  mySA.deposit (1248.31);
    System.out.println ("Actual:   "    + tempString  );
    System.out.println ("Expected: "  + 1248.31 + " deposited ");

    tempString = myMSA.deposit (134.00);
	 System.out.println ("Actual:   "    + tempString);
	 System.out.println ("Expected: Total Balance: $134.00" +
	 		" Available Balance: $134.00 Unavailable Balance: $0.00");
   
	 System.out.println ("\n End Test 5 \n"); 

			// test getBalance method - was balance updated?
    //6.
    tempDouble = myFTSA0.getBalance();
	 System.out.println (" Actual:   " + tempDouble);
	 System.out.println (" Expected: 365.65 ");
	
	 tempDouble = myFTSA1.getBalance();
	 System.out.println (" Actual:   " + tempDouble);
	 System.out.println (" Expected: 12345.6462 ");
	 
	 tempDouble = mySA.getBalance();
	 System.out.println (" Actual:   " + tempDouble);
	 System.out.println (" Expected: 1248.31 ");

    tempDouble = myMSA.getBalance();
	 System.out.println (" Actual:   " + tempDouble);
	 System.out.println (" Expected: 134.00 ");

    System.out.println ("\n End Test 6 \n");

          
				// test getBalanceMessage method - formatted output
    //7.
    tempString = myFTSA0.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: Balance: $365.65 ");

    tempString =   myFTSA1.getBalanceMessage(); // formatting rounds
    System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: Balance: $12,345.65");

	 tempString = mySA.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: Balance: $1,248.31 ");
  
    tempString = myMSA.getBalanceMessage();
    System.out.println ("Actual:   "    + tempString);
	 System.out.println ("Expected: Total Balance: $134.00" +
	 		" Available Balance: $134.00 Unavailable Balance: $0.00");
  
    System.out.println ("\n End Test 7 \n"); 

				// try additional deposits to Mixed Savings Account
				// which behaves differently from other accounts  
    //8.
    tempString = myMSA.deposit (327.12);
	 System.out.println ("Actual:   "    + tempString);
	 System.out.println ("Expected: Total Balance: $461.12" +
	 		" Available Balance: $250.00 Unavailable Balance: $211.12");

    tempString = myMSA.deposit (145.62);
	 System.out.println ("Actual:   "    + tempString);
	 System.out.println ("Expected: Total Balance: $606.74" +
	 		" Available Balance: $250.00 Unavailable Balance: $356.74");

    System.out.println ("\n End test 8 \n ");
        
  		// try negative deposits  to accounts
    //9.  
	 tempString =   myFTSA1.deposit(-12345.6462);
    System.out.println ("Actual:   " + tempString  );
    System.out.println ("Expected: "   + -12345.6462 + " is negative no money deposited");
    
    tempString =   myFTSA0.deposit(-365.65);
    System.out.println ("Actual:   "   + tempString  );
    System.out.println ("Expected: "  + -365.65 + " is negative no money deposited");
 
	 tempString =  mySA.deposit (-1248.31);
    System.out.println ("Actual:   "    + tempString  );
    System.out.println ("Expected: "  + -1248.31 + " is negative no money deposited");

    tempString =  myMSA.deposit (-128.73);
    System.out.println ("Actual:   "    + tempString  );
    System.out.println ("Expected: "  + -128.73 + " is negative no money deposited");
  
    System.out.println ("\n End test 9 \n ");

			// test correct withdraws from SavingsAccount and MixedSavingsAccount
    //10.
	 tempString = mySA.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: Balance: $1,248.31 ");
       
	 tempString = mySA.withdraw(251.13);
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: $251.13 successfully withdrawn");

	 tempString = mySA.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: Balance: $997.18 ");
   
    tempString = myMSA.getBalanceMessage();
	 System.out.println ("Actual:   "    + tempString);
	 System.out.println ("Expected: Total Balance: $606.74" +
	 		" Available Balance: $250.00 Unavailable Balance: $356.74 \n");
    	 
    tempString = myMSA.withdraw(120.00);
    System.out.println (" Result of trying to withdraw 120 is: " + tempString);
    tempString = myMSA.getBalanceMessage();
	 System.out.println ("Actual:   "    + tempString);
	 System.out.println ("Expected: Total Balance: $486.74" +
	 		" Available Balance: $130.00 Unavailable Balance: $356.74");
 	
	System.out.println (" \n End of test 10 \n ");
	 
           // test incorrect withdraw from Savings Account
	 //11.
	 tempString = mySA.withdraw(1251.13);
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: Not enough money in account to withdraw $1,251.13 ");

	 tempString = mySA.getBalanceMessage();
	 System.out.println (" Actual:   " + tempString);
	 System.out.println (" Expected: Balance: $997.18 ");
	 
	 tempString = myMSA.withdraw(350.00);
    System.out.println (" Result of trying to withdraw 350 is: " + tempString);
    tempString = myMSA.getBalanceMessage();
	 System.out.println ("Actual:   "    + tempString);
	 System.out.println ("Expected: Total Balance: $486.74" +
	 		" Available Balance: $130.00 Unavailable Balance: $356.74");

  } // end main
  
} // end class  