`  1  /**`
`  2     A bank account has a balance that can be changed by `
`  3     deposits and withdrawals.`
`  4  */`
`  5  public class BankAccount`
`  6  {  `
`  7     private double balance;`
`  8     private int accountNumber;`
`  9     private static int lastAssignedNumber = 1000;`
` 10  `
` 11     public static final double OVERDRAFT_FEE = 29.95;`
` 12  `
` 13     /**`
` 14        Constructs a bank account with a zero balance.`
` 15     */`
` 16     public BankAccount()`
` 17     {   `
` 18        lastAssignedNumber++;`
` 19        accountNumber = lastAssignedNumber;`
` 20        balance = 0;`
` 21     }`
` 22  `
` 23     /**`
` 24        Constructs a bank account with a given balance.`
` 25        @param initialBalance the initial balance`
` 26     */`
` 27     public BankAccount(double initialBalance)`
` 28     {   `
` 29        balance = initialBalance;`
` 30     }`
` 31  `
` 32     /**`
` 33        Deposits money into this account.`
` 34        @param amount the amount to deposit`
` 35     */`
` 36     public void deposit(double amount)`
` 37     {  `
` 38        balance = balance + amount;`
` 39     }`
` 40  `
` 41     /**`
` 42        Makes a withdrawal from this account, or charges a penalty if`
` 43        sufficient funds are not available.`
` 44        @param amount the amount of the withdrawal`
` 45     */`
` 46     public void withdraw(double amount)`
` 47     {   `
` 48        if (amount > balance)`
` 49        {`
` 50           balance = balance - OVERDRAFT_FEE;`
` 51        }`
` 52        else`
` 53        {`
` 54           balance = balance - amount;`
` 55        }`
` 56     }`
` 57  `
` 58     /**`
` 59        Adds interest to this account.`
` 60        @param rate the interest rate in percent`
` 61     */`
` 62     public void addInterest(double rate)`
` 63     {   `
` 64        balance = balance + Financial.percentOf(rate, balance);`
` 65     }`
` 66  `
` 67     /**`
` 68        Gets the current balance of this account.`
` 69        @return the current balance`
` 70     */`
` 71     public double getBalance()`
` 72     {   `
` 73        return balance;`
` 74     }`
` 75  }`