Exemplo n.º 1
0
        public static void ShowDemo()
        {
            Console.WriteLine("测试备忘录模式 --- 象棋的例子");

            MementoCaretaker mc = new MementoCaretaker();

            Chessman chess = new Chessman("车", 1, 1);

            display(chess);

            mc.setMemento(chess.save());         //保存状态

            chess.Y = 4;
            display(chess);

            mc.setMemento(chess.save());         //保存状态
            display(chess);

            chess.X = 5;
            display(chess);

            Console.WriteLine("******悔棋******");

            chess.restore(mc.getMemento());         //恢复状态
            display(chess);
        }
Exemplo n.º 2
0
        public static void ShowDemo()
        {
            Console.WriteLine("测试备忘录模式 --- 象棋的例子");

            MementoCaretaker mc = new MementoCaretaker();

            Chessman chess = new Chessman("车",1,1);
            display(chess);

            mc.setMemento(chess.save()); //保存状态

            chess.Y = 4;
            display(chess);

            mc.setMemento(chess.save()); //保存状态
            display(chess);

            chess.X = 5;
            display(chess);

            Console.WriteLine("******悔棋******");

            chess.restore(mc.getMemento()); //恢复状态
            display(chess);
        }
Exemplo n.º 3
0
 public static void display(Chessman chess)
 {
     Console.WriteLine("棋子" + chess.Label + "当前位置为:" + "第" + chess.X + "行" + "第" + chess.Y + "列。");
 }
Exemplo n.º 4
0
 public static void display(Chessman chess)
 {
     Console.WriteLine("棋子" + chess.Label + "当前位置为:" + "第" + chess.X + "行" + "第" + chess.Y + "列。");
 }