/** * Implements a simple bank account enabling you to deposit and withdraw money * as well as check your balance. * * @author wollowsk. * Created Sep 7, 2010. */ public class BankAccount{ private double balance; /** * Creates a new, empty bank account. * */ public BankAccount() { this.balance = 0; } /** * Creates a new bank account with an initial deposit. * * @param initialBalance The amount of money deposited when opening an account. */ public BankAccount(double initialBalance) { this.balance = initialBalance; } /** * Enables a user to deposit money. * * @param amount Amount to be deposited. */ public void deposit(double amount) { double newAmount = this.balance + amount; this.balance += amount; } public void withdraw(double amount) { balance -= amount; } public double getBalance() { return balance; } }