|
FeeAccount |
|
1 // joi/7/bank/FeeAccount.java
2 //
3 //
4 // Copyright 2003 Bill Campbell and Ethan Bolker
5
6 /**
7 * A FeeAccount is a BankAccount with one new feature:
8 * the user is charged for each transaction.
9 *
10 * @see BankAccount
11 *
12 * @version 7
13 */
14
15 public class FeeAccount extends BankAccount
16 {
17 /**
18 * Constructor, accepting an initial balance and issuing Bank.
19 *
20 * @param initialBalance the opening balance.
21 * @param issuingBank the bank that issued this account.
22 *
23 * @exception InsufficientFundsException when appropriate.
24 */
25
26 public FeeAccount( int initialBalance, Bank issuingBank )
27 throws InsufficientFundsException
28 {
29 super( initialBalance, issuingBank);
30 }
31
32 /**
33 * The Bank's transaction fee.
34 *
35 * @return the fee.
36 */
37
38 protected int getTransactionFee()
39 {
40 return getIssuingBank().getTransactionFee();
41 }
42
43 /**
44 * The way a transaction is counted for a FeeAccount: it levies
45 * a transaction fee as well as counting the transaction.
46 *
47 * @exception InsufficientFundsException when appropriate.
48 */
49
50 public void countTransaction()
51 throws InsufficientFundsException
52 {
53 incrementBalance( - getTransactionFee() );
54 super.countTransaction();
55 }
56
57 /**
58 * A FeeAccount incurs a monthly charge.
59 *
60 * @exception InsufficientFundsException when appropriate.
61 */
62
63 public void newMonth()
64 throws InsufficientFundsException
65 {
66 incrementBalance( - getIssuingBank().getMonthlyCharge());
67 }
68 }
69
|
FeeAccount |
|