/** * A bank account has a balance that can be changed by deposits and withdrawals */ public class BankAccount2 implements Measurable { private double balance ; /** * Creates a bank account with a given balance * @param initialBalance the initial balance */ public BankAccount2(double initialBalance) { balance = initialBalance; } /** * Deposits money into the bank account * @param amount the amount to deposit */ public void deposit(double amount) { double newBalance = balance + amount; balance = newBalance; } /** * Withdraws money from the bank account * @param amount the amount to withdraw */ public void withdraw(double amount) { double newBalance = balance - amount; balance = newBalance; } /** * Gets the current balance of the bank account. * @return the current balance */ public double getBalance() { return balance; } /********************************************************************* * Note to students: method getMeasure (below) implements the abstract* * getMeasure method of the Measurable interface, as required * *********************************************************************/ /** * Gets the measure of the bank account * @return the current balance */ public double getMeasure() { return balance; } }