// Helene Martin, CSE 142 // Models bank accounts public class BankAccount { private int accountNum; private double balance; // should always be >=0 private int transaction; private String username; // lots of other possible fields: // type (savings/checking) // interest rate // list of transactions public BankAccount(int num, double initialBalance, String name) { accountNum = num; balance = initialBalance; // should check it's positive username = name; } // returns the account owner's name public String getName() { return username; } // deposit a certain amount of money // pre: money must be positive // (could return new balance, true/false based on success...) public void deposit(double money) { if (money >= 0) { balance += money; } } // withdraw a certain amount of money // pre: money must be positive and <= balance public void withdraw(double money) { if (balance >= money && money >= 0) { balance -= money; } } }