Java Reference
In-Depth Information
19 harrysChecking.withdraw( 80 );
20
21 momsSavings.transfer( 1000 ,
harrysChecking);
22 harrysChecking.withdraw( 400 );
23
24 // Simulate end of month
25 momsSavings.addInterest();
26 harrysChecking.deductFees();
27
28 System.out.println( ÐMom's savings
balance: Ñ
29 + momsSavings.getBalance());
30 System.out.println( ÐExpected: 7035Ñ );
31
32 System.out.println( ÐHarry's checking
balance: Ñ
33 + harrysChecking.getBalance());
34 System.out.println( ÐExpected: 1116Ñ );
35 }
36 }
456
457
ch10/accounts/BankAccount.java
1 /**
2 A bank account has a balance that can be changed by
3 deposits and withdrawals.
4 */
5 public class BankAccount
6 {
7 /**
8 Constructs a bank account with a zero balance.
9 */
10 public BankAccount()
11 {
12 balance = 0 ;
13 }
14
15 /**
16 Constructs a bank account with a given balance.
17 @param initialBalance the initial balance
18 */
19 public BankAccount( double initialBalance)
Search WWH ::




Custom Search