//BankAccount.java source code /** * A bank account has a balance that can be changed by * deposits and withdrawals. */ public class BankAccount { /** Construct a bank account with a zero balance. */ public BankAccount() { this.balance = 0; } /** Construct a bank account with a given balance. * @param initialBalance the initial balance */ public BankAccount(double initialBalance) { this.balance = initialBalance; } /** Deposit money into the bank account. * @param amount the amount to deposit */ public void deposit(double amount) { double updatedBalance = this.balance + amount; this.balance = updatedBalance; } /** * Withdraw money from the bank account. * @param amount the amount to withdraw */ public void withdraw(double amount) { double updatedBalance = this.balance - amount; this.balance = updatedBalance; } /** * Get the current balance of the bank account. * @return the current balance */ public double getBalance() { return this.balance; } private double balance; }