/******************************************************************
 * Program: CreditCardAccountTester
 *
 * Programmer: Tyler Johnson
 *
 * Due Date: N/A

 *
 * COMP 110-001        Instructor: Tyler Johnson
 *
 * Description: This driver program performs various tests on the 
 *				functionality of the CreditCardAccount class.
 *
 ******************************************************************/

public class CreditCardAccountTester  {

	public static void main(String[] args) throws Exception {
	
		CreditCardAccount accnt = new CreditCardAccount();
		
		final int SLEEP_AMNT = 500;
		
		/*************************************
		*
		*	Test get/setAccntHolder
		*
		**************************************/
		
		String holder = "John Wayne";
		
		accnt.setAccntHolder(holder);

		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing get/setAccntHolder: ");
		Thread.sleep(SLEEP_AMNT);	
		
		if(accnt.getAccntHolder().equals(holder))
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
			
		holder = "Bazooka Joe";
		
		accnt.setAccntHolder(holder);

		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing get/setAccntHolder: ");
		Thread.sleep(SLEEP_AMNT);	
			
		if(accnt.getAccntHolder().equals(holder))
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
			
		/*************************************
		*
		*	Test get/setAccntNum
		*
		**************************************/
			
		String accntNumber = "4094240204204224094";
		
		accnt.setAccntNum(accntNumber);
		
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing get/setAccntNum: ");
		Thread.sleep(SLEEP_AMNT);
				
		if(accnt.getAccntNum().equals(accntNumber))
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
			
		accntNumber = "2938414393471783";
		
		accnt.setAccntNum(accntNumber);
		
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing get/setAccntNum: ");
		Thread.sleep(SLEEP_AMNT);	
			
		if(accnt.getAccntNum().equals(accntNumber))
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
			
		/*************************************
		*
		*	Test setLimit
		*
		**************************************/
		
		double limit = 1000+100*Math.random();
		
		accnt.setLimit(limit);
			
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing get/setLimit: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(accnt.getLimit() == limit)
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
			
			
		/*************************************
		*
		*	Test get/setInterestRate
		*
		**************************************/

		double interest = 1+5*Math.random();
		
		accnt.setInterestRate(interest);
			
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing get/setInterestRate: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(accnt.getInterestRate() == interest)
			System.out.println("PASSED");
		else
			System.out.println("FAILED");


		/*************************************
		*
		*	Test getBalance & addPurchase
		*
		**************************************/
		
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing getBalance: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(accnt.getBalance() == 0.0)
			System.out.println("PASSED");
		else
			System.out.println("FAILED");

		double purchase = 1+100*Math.random();
		
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing addPurchase: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(accnt.addPurchase(purchase))
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
		
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing getBalance: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(accnt.getBalance() == purchase)
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
			
		double purchase2 = 1+100*Math.random();
		
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing addPurchase: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(accnt.addPurchase(purchase2))
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
		
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing getBalance: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(accnt.getBalance() == purchase + purchase2)
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
						
		//should fail, we're over limit
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing addPurchase: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(!accnt.addPurchase(limit))
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
			
		//balance shouldn't have changed
			
		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing getBalance: ");	
		Thread.sleep(SLEEP_AMNT);
		
		if(accnt.getBalance() == purchase + purchase2)
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
			
			
		/*************************************
		*
		*	Test computeInterest
		*
		**************************************/

		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing computeInterest: ");	
		Thread.sleep(SLEEP_AMNT);
		
		accnt.computeInterest();
		
		if(Math.abs(accnt.getBalance() - (1+interest)*(purchase + purchase2)) < 0.01)
			System.out.println("PASSED");
		else
			System.out.println("FAILED");


		Thread.sleep(SLEEP_AMNT);	
		System.out.print("Testing computeInterest: ");	
		Thread.sleep(SLEEP_AMNT);
		
		accnt.computeInterest();
		
		if(Math.abs(accnt.getBalance() - (1+interest)*(1+interest)*(purchase + purchase2)) < 0.01)
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
	}
}