/** * This is a simplified version of the BankAccount class that we * designed together in-class. * * This class has only 4 instance variables: * - balance, * - interest rate, * - name, * - account number */ public class SimpleBankAccount{ // Instance variables private double balance; private double interestRate; private String ownerName; private String accountNumber; /** * Constructs a new bank account */ public SimpleBankAccount(String name, double initialBalance, String aNumber){ balance = initialBalance; interestRate = 0.03; ownerName = name; accountNumber = aNumber; } /** * Adds interest to the account */ public double addInterest(){ double interest = balance * interestRate; balance = balance + interest; return balance; } /** * Deposits money into the account */ public double deposit(double amount){ balance = balance + amount; return balance; } /** * Withdraws money from the account */ public double withdrawal(double amount){ balance = balance - amount; return balance; } /** * Returns the current balance */ public double getBalance(){ return balance; } /** * Returns the name of the account owner */ public String getOwnerName(){ return ownerName; } /** * Returns the account number */ public String getAccountNumber(){ return accountNumber; } /** * Returns a String representing the state of the object */ public String toString(){ return "[" + ownerName + ", " + accountNumber + ", " + balance + "]"; } }