コード例 #1
0
        public static void editSingleTask(Task_impl task, Task_manager_impl tm, ConsoleIO_impl IO)
        {
            IO.clear();
            IO.print("Задание: " + task.Task_text);
            IO.print("Введите новое: ");
            string text = IO.getStringFromUser();

            IO.print("Дата задания: " + task.Task_date.ToString().Substring(0, 10));
            IO.print("Введите новую дату: ");
            DateTime time = IO.getDateFromUser();

            IO.print("Статус задания: " + (task.Task_completion ? "[X]" : "[ ]"));
            string phrase = "Введите новый статус:\n"
                            + "1)Выполнено\n"
                            + "2)Не выполнено";

            IO.print(phrase);
            ConsoleKeyInfo cki;
            int            status = -1;

            do
            {
                cki = IO.getKeyFromUser();
                if (cki.Key == ConsoleKey.Escape)
                {
                    break;
                }
                bool v = int.TryParse(cki.Key.ToString().Substring(1), out status);
                if (!v || status < 1 || status > 2)
                {
                    IO.clear(); IO.print("Ошибка! Неверное значение.\n" + phrase);
                }
            } while (status < 1 || status > 2);

            tm.changeTask(task, text, time, status == 1 ? true : false);
        }