Beispiel #1
0
        static void ManipulateTask()
        {
            Console.Write("Press 1 to make a new task, or press 2 to delete a task: ");
            string readOrDel = string.Empty;

            while (true)
            {
                readOrDel = Console.ReadLine();
                if (readOrDel != "1" && readOrDel != "2")
                {
                    Console.WriteLine("Incorect choice! Please try again!");
                }
                else if (readOrDel == "1")
                {
                    TaskMaker();
                    string choice = string.Empty;
                    while (true)
                    {
                        Console.Write("Do you want to make another task? yes/no");
                        choice = Console.ReadLine();
                        if (choice != "yes" && choice != "no")
                        {
                            Console.WriteLine("Incorect choice! Please try again!");
                        }
                        else if (choice == "yes")
                        {
                            TaskMaker();
                        }
                        else if (choice == "no")
                        {
                            Console.WriteLine("Good luck!");
                            Console.Write("Press any key to exit:");
                            return;
                        }
                    }
                }
                else if (readOrDel == "2")
                {
                    XMLTaskReader reader = new XMLTaskReader();
                    List <Task>   tasks  = reader.ReadTasks("../../tasks.xml");
                    Console.Write("Select the number of the task, you want to delete: ");
                    int           n      = int.Parse(Console.ReadLine());
                    XMLTaskWriter writer = new XMLTaskWriter();
                    writer.Delete(tasks[n - 1]);
                    Console.WriteLine("Delete completed!");
                    break;
                }
            }
        }
Beispiel #2
0
        static void TaskMaker()
        {
            Console.Write("Enter a title: ");
            string title = Console.ReadLine();

            Console.Write("Enter a description: ");
            string message = Console.ReadLine();

            Console.Write("How many days you need to finish the task: ");
            int deadLine = int.Parse(Console.ReadLine());

            var task = new Task(title, message, deadLine);

            Console.WriteLine("Do you want to save this task? yes/no");

            string choice;

            while (true)
            {
                choice = Console.ReadLine();
                if (choice != "yes" && choice != "no")
                {
                    Console.WriteLine("Incorect choice! Please try again!");
                }
                else if (choice == "yes")
                {
                    XMLTaskWriter writer = new XMLTaskWriter();
                    writer.Save(task);
                    Console.WriteLine("Save completed!");
                    return;
                }
                else if (choice == "no")
                {
                    Console.WriteLine("Good luck!");
                    return;
                }
            }
        }