|
CheckingAccount |
|
1 // joi/5/bank/CheckingAccount.java
2 //
3 //
4 // Copyright 2003 Bill Campbell and Ethan Bolker
5
6 /**
7 * A CheckingAccount is a BankAccount with one new feature:
8 * the ability to cash a check by calling the honorCheck method.
9 * Each honored check costs the customer a checkFee.
10 *
11 * @version 5
12 */
13
14 public class CheckingAccount extends BankAccount
15 {
16 private static int checkFee = 2; // pretty steep for each check
17
18 /**
19 * Constructs a CheckingAccount with the given
20 * initial balance and issuing Bank.
21 * Counts as this account's first transaction.
22 *
23 * @param initialBalance the opening balance for this account.
24 * @param issuingBank the bank that issued this account.
25 */
26
27 public CheckingAccount( int initialBalance, Bank issuingBank )
28 {
29 super( initialBalance, issuingBank );
30 }
31
32 /**
33 * Honor a check:
34 * Charge the account the appropriate fee
35 * and withdraw the amount.
36 *
37 * @param amount amount (in whole dollars) to be withdrawn.
38 * @return the amount withdrawn.
39 */
40
41 public int honorCheck( int amount )
42 {
43 incrementBalance( - checkFee );
44 return withdraw( amount );
45 }
46
47 /**
48 * Action to take when a new month starts.
49 */
50
51 public void newMonth()
52 {
53 }
54 }
55
|
CheckingAccount |
|