Exemplo n.º 1
0
        // Mementos are used to roll back states arbitrarily
        // A memento is simply a token/handle class with (typically) no functions of its own
        // A memento is not required to expose directly the state(s) to which it reverts the system
        // Can be used to implement undo/redo
        public static void AdvancedDemo()
        {
            var ba = new BankAccountV2(100);

            ba.Deposit(50);
            ba.Deposit(25);
            WriteLine(ba);

            ba.Undo();
            WriteLine($"Undo 1: {ba}");
            ba.Undo();
            WriteLine($"Undo 2: {ba}");
            ba.Redo();
            WriteLine($"Redo 2: {ba}");
        }