Exemple #1
0
        private static void RunToDoDemo()
        {
            ToDoItem toDoItem = new ToDoItem(
                "Buy bread",
                "Go TO bakery",
                new DateTime(2021, 5, 7, 13, 55, 55)
                );
            Memento   memento   = toDoItem.StoreState();
            CareTaker careTaker = new CareTaker();

            careTaker.Save("Bread", memento);

            Console.WriteLine(toDoItem);
            toDoItem.Rename("Buy milk");
            toDoItem.ChangeTask("Go to milk shop");
            careTaker.Save("Milk", toDoItem.StoreState());

            Console.WriteLine(toDoItem);
            toDoItem.RestoreState(careTaker.GetState("Bread"));
            Console.WriteLine(toDoItem);
            toDoItem.RestoreState(careTaker.GetState("Milk"));
            Console.WriteLine(toDoItem);
        }