import java.util.*; /** * The "Model" i.e., the Account information */ public class Model extends Observable { /** * The data we hold */ private String name; private int balance; public Model (String name, int balance) { this.name = name; setBalance (balance); } public void withdraw (int amount) { setBalance (balance - amount); } public void deposit (int amount) { setBalance (balance + amount); } /** * Set our balance -- and then we notify our Observers */ private void setBalance (int balance) { this.balance = balance; // Must call this before notifyObservers() setChanged(); // Tells any Observers we have that we have changed notifyObservers(); } public int getBalance () { return balance; } public String getName () { return name; } }