コード例 #1
0
        public Memento2 Deposit(int amount)
        {
            balance += amount;
            var m = new Memento2(balance);

            changes.Add(m);
            ++current;
            return(m);
        }
コード例 #2
0
        // 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);
        }