1 /**
2 A checking account has a limited number of free deposits and withdrawals.
3 */
4 public class CheckingAccount extends BankAccount
5 {
6 private int withdrawals;
7
8 /**
9 Constructs a checking account with a zero balance.
10 */
11 public CheckingAccount()
12 {
13 withdrawals = 0;
14 }
15
16 public void withdraw(double amount)
17 {
18 final int FREE_WITHDRAWALS = 3;
19 final int WITHDRAWAL_FEE = 1;
20
21 super.withdraw(amount);
22 withdrawals++;
23 if (withdrawals > FREE_WITHDRAWALS)
24 {
25 super.withdraw(WITHDRAWAL_FEE);
26 }
27 }
28
29 public void monthEnd()
30 {
31 withdrawals = 0;
32 }
33 }
34