Skip to content

Instantly share code, notes, and snippets.

@tatey
Created August 13, 2008 04:14
Show Gist options
  • Save tatey/5194 to your computer and use it in GitHub Desktop.
Save tatey/5194 to your computer and use it in GitHub Desktop.
Solution to Lab 3 test class for 1005ICT
/**
* Write a description of class AccountTester here.
*
* @author Tate Johnson
* @version 2008-07-08
*/
public class AccountTester {
public static void main(String[] args) {
// Instantiate two accounts for testing
System.out.println("Creating accounts...");
Account ac1 = new Account("John");
Account ac2 = new Account("Mary");
// Deposit funds into each account
System.out.println("Depositing funds in to accounts...");
ac1.deposit(100);
ac2.deposit(500);
// Show balances of each account
System.out.println("Account #1 has balance: " + ac1.balance());
System.out.println("Account #2 has balance: " + ac2.balance());
// Show total deposits
System.out.println("Total deposits: " + Account.totalDeposits());
// Attempt to overdraw account
System.out.println("Attempting to overdraw account...");
System.out.println("False indicates that withdrawel was denied: [" + ac1.withdraw(150) + "]");
// Withdraw funds from account
System.out.println("Withdrawing funds from accounts...");
ac1.withdraw(50);
ac2.withdraw(100);
// Show account name, id and balance after withdrawing
System.out.println("Account #1: " + ac1.toString());
System.out.println("Account #2: " + ac2.toString());
// Show total interest for 12 months
System.out.println("Calculating total interest on accounts at 10%...");
System.out.println(ac1.calcInterest(0.1));
System.out.println(ac2.calcInterest(0.1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment