FileDocCategorySizeDatePackage
Account_Impl.javaAPI DocExample1566Thu Nov 08 00:23:18 GMT 2001com.ora.rmibook.chapter18.bank

Account_Impl

public class Account_Impl extends UnicastRemoteObject implements Account

Fields Summary
private Money
_balance
Constructors Summary
public Account_Impl(Money startingBalance)

        super (0, new SSLSocket_RMIClientSocketFactory(),
            new SSLSocket_RMIServerSocketFactory());
        _balance = startingBalance;
    
Methods Summary
private voidcheckForNegativeAmount(Money amount)

        int cents = amount.getCents();

        if (0 > cents) {
            throw new NegativeAmountException();
        }
    
private voidcheckForOverdraft(Money amount)

        if (amount.greaterThan(_balance)) {
            throw new OverdraftException(false);
        }
        return;
    
public MoneygetBalance()

        return _balance;
    
public voidmakeDeposit(Money amount)

        checkForNegativeAmount(amount);
        _balance.add(amount);
        return;
    
public voidmakeWithdrawal(Money amount)

        checkForNegativeAmount(amount);
        checkForOverdraft(amount);
        _balance.subtract(amount);
        return;