Java Reference
In-Depth Information
62 private double balance;
63 }
ch10/accounts/CheckingAccount.java
1 /**
2 A checking account that charges transaction fees.
3 */
4 public class CheckingAccount extends
BankAccount
5 {
6 /**
7 Constructs a checking account with a given balance.
8 @param initialBalance the initial balance
9 */
10 public CheckingAccount( double
initialBalance)
11 {
12 // Construct superclass
13 super (initialBalance);
14
15 // Initialize transaction count
16 transactionCount = 0 ;
17 }
18
19 public void deposit( double amount)
20 {
21 transactionCount++;
22 // Now add amount to balance
23 super .deposit(amount);
24 }
25
26 public void withdraw( double amount)
27 {
28 transactionCount++;
29 // Now subtract amount from balance
30 super .withdraw(amount);
31 }
32
33 /**
34 Deducts the accumulated fees and resets the
35 transaction count.
Search WWH ::




Custom Search