Exemplo n.º 1
0
 public Originator(double x, double y, CareTaker careTaker)
 {
     X          = x;
     Y          = y;
     _careTaker = careTaker;
     CreateSavePoint(_initialSavePointName);
 }
Exemplo n.º 2
0
 public Originator(double x, double y, CareTaker careTaker)
 {
     CreateSavePoint("INITIAL");
     X          = x;
     Y          = y;
     _careTaker = careTaker;
 }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            var careTaker  = new CareTaker();
            var originator = new Originator(5, 10, careTaker);

            Console.WriteLine($"Default State: {originator}");

            originator.X = originator.Y * 51;
            Console.WriteLine($"State: {originator}");

            originator.CreateSavepoint("SAVE1");
            originator.Y = originator.X / 22;
            Console.WriteLine($"State: {originator}");

            originator.Undo();
            Console.WriteLine($"State after undo: {originator}");

            originator.X = Math.Pow(originator.X, 3);
            originator.CreateSavepoint("SAVE2");
            Console.WriteLine($"State: {originator}");

            originator.Y = originator.X - 30;
            originator.CreateSavepoint("SAVE3");
            Console.WriteLine($"State: {originator}");

            originator.Y = originator.X / 22;
            originator.CreateSavepoint("SAVE4");
            Console.WriteLine($"State: {originator}");

            originator.Undo("SAVE2");
            Console.WriteLine($"Retrieving at: {originator}");
            originator.UndoAll();
            Console.WriteLine($"State after undo all: {originator}");
        }
Exemplo n.º 4
0
 public Originator(double x, double y, CareTaker careTaker)
 {
     CreateSavePoint("INITIAL");
     throw new System.NotImplementedException();
 }