01: import java.io.Serializable;
02: 
03: /**
04:    A bank account has a balance that can be changed by 
05:    deposits and withdrawals.
06: */
07: public class BankAccount implements Serializable
08: {  
09:    /**
10:       Constructs a bank account with a zero balance.
11:       @param anAccountNumber the account number for this account
12:    */
13:    public BankAccount(int anAccountNumber)
14:    {   
15:       accountNumber = anAccountNumber;
16:       balance = 0;
17:    }
18: 
19:    /**
20:       Constructs a bank account with a given balance.
21:       @param anAccountNumber the account number for this account
22:       @param initialBalance the initial balance
23:    */
24:    public BankAccount(int anAccountNumber, double initialBalance)
25:    {   
26:       accountNumber = anAccountNumber;
27:       balance = initialBalance;
28:    }
29: 
30:    /**
31:       Gets the account number of this bank account.
32:       @return the account number
33:    */
34:    public int getAccountNumber()
35:    {   
36:       return accountNumber;
37:    }
38: 
39:    /**
40:       Deposits money into the bank account.
41:       @param amount the amount to deposit
42:    */
43:    public void deposit(double amount)
44:    {  
45:       double newBalance = balance + amount;
46:       balance = newBalance;
47:    }
48: 
49:    /**
50:       Withdraws money from the bank account.
51:       @param amount the amount to withdraw
52:    */
53:    public void withdraw(double amount)
54:    {   
55:       double newBalance = balance - amount;
56:       balance = newBalance;
57:    }
58: 
59:    /**
60:       Gets the current balance of the bank account.
61:       @return the current balance
62:    */
63:    public double getBalance()
64:    {   
65:       return balance;
66:    }
67: 
68:    private int accountNumber;
69:    private double balance;
70: }