Methods Summary |
---|
private void | checkAccess()
String clientHost = wrapperAroundGetClientHost();
if (null == _currentClient) {
_currentClient = clientHost;
} else {
if (!_currentClient.equals(clientHost)) {
throw new LockedAccountException();
}
}
resetCounter();
return;
|
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 synchronized Money | getBalance()
checkAccess();
return _balance;
|
public synchronized void | makeDeposit(Money amount)
checkAccess();
checkForNegativeAmount(amount);
_balance.add(amount);
return;
|
public synchronized void | makeWithdrawal(Money amount)
checkAccess();
checkForNegativeAmount(amount);
checkForOverdraft(amount);
_balance.subtract(amount);
return;
|
private void | releaseLock()
if (null != _currentClient) {
_currentClient = null;
}
|
private void | resetCounter()
_timeLeftUntilLockIsReleased = TIMER_DURATION;
|
private java.lang.String | wrapperAroundGetClientHost()
String clientHost = null;
try {
clientHost = getClientHost();
} catch (ServerNotActiveException ignored) {
}
return clientHost;
|