/** A simple bank account * @author Hal Perkins */ public class BankAccount { // instance variables private int number; // account number private String name; // account name private double balance; // account balance /** Return the current balance of this BankAccount */ public double getBalance() { return balance; } /** Return this BankAccount's name */ public String getName() { return name; } /** Return this BankAccount's number */ public int getNumber() { return number; } /** set this BankAccount's name to newName */ public void setName(String newName) { name = newName; } /** set this BankAccount's number to newNumber */ public void setNumber(int newNumber) { number = newNumber; } /** Deposit amount in this BankAccount */ public void deposit(double amount) { balance = balance + amount; } /** Withdraw amount from this BankAccount */ public void withdraw(double amount) { balance = balance - amount; } /** Transfer given amount from otherAccount */ public void transferFrom(BankAccount otherAccount, double amount) { balance = balance + amount; otherAccount.withdraw(amount); } /** Initialize a new BankAccount with the given * account name and number and a balance of 0.0 */ public BankAccount(int accountNumber, String accountName){ number = accountNumber; name = accountName; balance = 0.0; } }