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:       @param anAccountNumber the account number for this account
10:    */
11:    public BankAccount(int anAccountNumber)
12:    {   
13:       accountNumber = anAccountNumber;
14:       balance = 0;
15:    }
16: 
17:    /**
18:       Constructs a bank account with a given balance
19:       @param anAccountNumber the account number for this account
20:       @param initialBalance the initial balance
21:    */
22:    public BankAccount(int anAccountNumber, double initialBalance)
23:    {   
24:       accountNumber = anAccountNumber;
25:       balance = initialBalance;
26:    }
27: 
28:    /**
29:       Gets the account number of this bank account.
30:       @return the account number
31:    */
32:    public int getAccountNumber()
33:    {   
34:       return accountNumber;
35:    }
36: 
37:    /**
38:       Deposits money into the bank account.
39:       @param amount the amount to deposit
40:    */
41:    public void deposit(double amount)
42:    {  
43:       double newBalance = balance + amount;
44:       balance = newBalance;
45:    }
46: 
47:    /**
48:       Withdraws money from the bank account.
49:       @param amount the amount to withdraw
50:    */
51:    public void withdraw(double amount)
52:    {   
53:       double newBalance = balance - amount;
54:       balance = newBalance;
55:    }
56: 
57:    /**
58:       Gets the current balance of the bank account.
59:       @return the current balance
60:    */
61:    public double getBalance()
62:    {   
63:       return balance;
64:    }
65: 
66:    private int accountNumber;
67:    private double balance;
68: }