Exemplo n.º 1
0
        // 撤销悔棋
        public static void Redo(Chessman chess, int i)
        {
            Console.WriteLine("---------- Sorry,撤销悔棋 ---------");
            index++;
            // 恢复到下一个备忘录
            chess.Restore(mementoCaretaker.GetMemento(i + 1));

            Console.WriteLine("棋子 {0} 当前位置为 第 {1} 行 第 {2} 列", chess.Label, chess.X, chess.Y);
        }
Exemplo n.º 2
0
        // 悔棋
        public static void Undo(Chessman chess, int i)
        {
            Console.WriteLine("---------- Sorry,俺悔棋了 ---------");
            index--;
            // 撤销到上一个备忘录
            chess.Restore(mementoCaretaker.GetMemento(i - 1));

            Console.WriteLine("棋子 {0} 当前位置为 第 {1} 行 第 {2} 列", chess.Label, chess.X, chess.Y);
        }