01: /**
02:    A bank account has a balance that can be changed by 
03:    deposits and withdrawals.
04: */
05: public class BankAccount
06: {
07:    /**
08:       Constructs a bank account with a zero balance.
09:    */
10:    public BankAccount()
11:    {
12:       balance = 0;
13:    }
14: 
15:    /**
16:       Deposits money into the bank account.
17:       @param amount the amount to deposit
18:    */
19:    public void deposit(double amount)
20:    {
21:       System.out.print("Depositing " + amount);
22:       double newBalance = balance + amount;
23:       System.out.println(", new balance is " + newBalance);
24:       balance = newBalance;
25:    }
26:    
27:    /**
28:       Withdraws money from the bank account.
29:       @param amount the amount to withdraw
30:    */
31:    public void withdraw(double amount)
32:    {
33:       System.out.print("Withdrawing " + amount);
34:       double newBalance = balance - amount;
35:       System.out.println(", new balance is " + newBalance);
36:       balance = newBalance;
37:    }
38:    
39:    /**
40:       Gets the current balance of the bank account.
41:       @return the current balance
42:    */
43:    public double getBalance()
44:    {
45:       return balance;
46:    }
47:    
48:    private double balance;
49: }