Methods Summary |
---|
private boolean | checkTransfer(Account src, float amt)
boolean approved = false;
try {
if (src.getBalance() >= amt) {
approved = true;
}
}
catch (RemoteException re) {
// If some remote exception occurred, then the transfer is still
// compromised, so return false
approved = false;
}
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 insufficient for transfer");
}
|
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);
}
|