Esempio n. 1
0
        static void Main(string[] args)
        {
            Notebook notebook       = new Notebook();
            Note     noteforremoval = null;

            for (int i = 0; i < 5; i++)
            {
                Note note = new Note("title" + i, "text" + i);
                notebook.AddNote(note);
                if (i == 3)
                {
                    noteforremoval = note;
                }
            }
            notebook.RemoveNote(noteforremoval);


            var date = new DateTime(2020, 5, 20, 19, 21, 10);

            ToDoItem  item      = new ToDoItem("Anto", "zadatak3", date);
            CareTaker careTaker = new CareTaker();

            careTaker.PushStack(item.StoreState());
            item.Rename("Ivic");
            item.ChangeTask("hehehe");
            item.RestoreState(careTaker.PopStack());
        }
Esempio n. 2
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);
        }