Methods Summary |
---|
private boolean | checkTransfer(Account src, float amt)
boolean approved = false;
if (src.getBalance() >= amt) {
approved = true;
}
return approved;
|
public void | deposit(float amt)
mBalance += amt;
// Log transaction...
System.out.println("--> Deposited " + amt + " into account " + getName());
System.out.println(" New balance: " + getBalance());
|
public float | getBalance()
return mBalance;
|
public java.lang.String | getName()
return mName;
|
public void | transfer(float amt, Account src)
if (checkTransfer(src, amt)) {
src.withdraw(amt);
this.deposit(amt);
// Log transaction...
System.out.println("--> Transferred " + amt + " from account " + getName());
System.out.println(" New balance: " + getBalance());
}
else {
throw new InsufficientFundsException("Source account balance is less " +
"than the requested transfer.");
}
|
public void | transferBatch(float[] amts, Account[] srcs)
// Iterate through the accounts and the amounts to be
// transferred from each
for (int i = 0; i < amts.length; i++) {
float amt = amts[i];
Account src = srcs[i];
// Make the transaction
this.transfer(amt, src);
}
|
public void | withdraw(float amt)
if (mBalance >= amt) {
mBalance -= amt;
// Log transaction...
System.out.println("--> Withdrew " + amt + " from account " + getName());
System.out.println(" New balance: " + getBalance());
}
else {
throw new InsufficientFundsException("Withdrawal request of " + amt +
" exceeds balance of " + mBalance);
}
|