import java.math.*; /** This class represents checking accounts. It implements state and behavior that define how a checking account differs from a general bank account. */ public class CheckingAccount extends BankAccount { /** Holds the string identifying the type of all checking accounts. */ private static final String ACCOUNT_TYPE = "C"; /** Holds the overdraft amount for this account. This is the amount by which a withdrawal or check can exceed the current balance. */ private BigDecimal overDraftLimit; /** Create a new empty checking account. Note that the superclass constructor is also executed. */ CheckingAccount() { } /** Return the account type string. */ public String getAccountType() { return ACCOUNT_TYPE; } /** Return the overdraft limit amount. */ public BigDecimal getOverDraftLimit() { if (overDraftLimit == null) setOverDraftLimit(new BigDecimal(0.0)); return overDraftLimit; } /** Return the maximum withdrawal amount. Withdrawals may be made up to the current balance plus the overdraft limit. */ public BigDecimal getWithdrawalLimit() { return getBalance().add(getOverDraftLimit()); } /** Set the overdraft limit amount. */ public void setOverDraftLimit(BigDecimal anAmount) { overDraftLimit = anAmount.setScale(2, BigDecimal.ROUND_HALF_DOWN); } }