/**
 * Representation for a checking account
 * 
 * @author Russell C. Bjork 
 * @version November 18, 2009
 */
public class CheckingAccount extends BankAccount
{
    private static double annualInterestRate;
    
    /**
     * Constructor for objects of class CheckingAccount
     * 
     * @param owner the owner of this account
     * 
     * The account number will be set to the first available unused number
     * The balance will be set to zero
     */
    public CheckingAccount(Customer owner)
    {
        super(owner);
    }

    /**
     * Withdraw money - override of method inherited from BankAccount.  If the
     * balance is insufficient, but the customer has a savings account with
     * a sufficient balance, withdraw the money from savings instead; otherwise
     * use the method inherited from the superclass.
     * 
     * @param amount the amount to withdraw (in cents)
     * @exception IllegalArgumentException if insufficient balance on hand
     */
    public void withdraw(int amount)
    {
        if (currentBalance < amount && owner.getSavingsAccount() != null &&
                owner.getSavingsAccount().currentBalance >= amount)
            owner.getSavingsAccount().withdraw(amount);
        else
            super.withdraw(amount);
    }
}
