/// <summary> /// This is just to try passing back in an invalid memento. /// </summary> public void BadExecute() { Console.WriteLine("\nBad Execute!\n"); ConstraintSolver solver = ConstraintSolver.Instance(); solver.ChangeState(); // Creating an object that is NOT a memento and storing it in the memento slot! object graphic = new Graphic(); _state = graphic; }
public override void Execute() { Console.WriteLine("\nExecute!\n"); ConstraintSolver solver = ConstraintSolver.Instance(); // This is done just to show the current state. solver.Solve(); // Create a memento // Acting as caretaker by storing it here _state = solver.CreateMemento(); // Move graphic _target.Move(_delta); // Adjust constraints for movement solver.ChangeState(); solver.Solve(); }