public Memento2 Deposit(int amount) { balance += amount; var m = new Memento2(balance); changes.Add(m); ++current; return(m); }
// add a restore state from memento public Memento2 Restore(Memento2 m) { // make sure there is something to undo. if (m != null) { balance = m.Balance; changes.Add(m); return(m); } return(null); }