Methods Summary |
---|
private void | checkForNegativeAmount(Money amount)
int cents = amount.getCents();
if (0 > cents) {
throw new NegativeAmountException();
}
|
private void | checkForOverdraft(Money amount)
if (amount.greaterThan(_balance)) {
throw new OverdraftException(false);
}
return;
|
public boolean | equals(java.lang.Object object)
// three cases. Either it's us, or it's our stub, or it's
// not equal.
if (object instanceof Account_Impl) {
return (object == this);
}
if (object instanceof RemoteStub) {
try {
RemoteStub ourStub = (RemoteStub) RemoteObject.toStub(this);
return ourStub.equals(object);
} catch (NoSuchObjectException e) {
// we're not listening on a port, therefore it's not our
// stub
}
}
return false;
|
public Money | getBalance()
return _balance;
|
public int | hashCode()
try {
Remote ourStub = RemoteObject.toStub(this);
return ourStub.hashCode();
} catch (NoSuchObjectException e) {
}
return super.hashCode();
|
public void | makeDeposit(Money amount)
checkForNegativeAmount(amount);
_balance.add(amount);
return;
|
public void | makeWithdrawal(Money amount)
checkForNegativeAmount(amount);
checkForOverdraft(amount);
_balance.subtract(amount);
return;
|