/** A bank account has a balance that can be changed by deposits and withdrawals. */ public class BankAccount { private int accountNumber; private double balance; /** Constructs a bank account with a zero balance. */ public BankAccount(int anAccountNumber) { accountNumber = anAccountNumber; balance = 0; } /** Constructs a bank account with a given balance. */ public BankAccount(int anAccountNumber, double initialBalance) { accountNumber = anAccountNumber; balance = initialBalance; } /** Gets the account number of this bank account. */ public int getAccountNumber() { return accountNumber; } /** Deposits money into the bank account. */ public void deposit(double amount) { double newBalance = balance + amount; balance = newBalance; } /** Withdraws money from the bank account. */ public void withdraw(double amount) { double newBalance = balance - amount; balance = newBalance; } /** Gets the current balance of the bank account. */ public double getBalance() { return balance; } }