Пример #1
0
        internal void Run()
        {
            var app = new TodoApp();

            app.List();

            string commandText;

            do
            {
                Console.Write(">");
                commandText = Console.ReadLine().ToLower().Trim();

                if (IsCommmand(commandText))
                {
                    switch (commandText)
                    {
                    case "help":
                        WriteHelp();
                        break;

                    case "list":
                        app.List();
                        break;

                    case "add":
                        app.Add();
                        break;

                    case "done":
                        app.SetDone();
                        break;

                    case "undone":
                        app.Undone();
                        break;

                    case "remove":
                        app.Remove();
                        break;

                    case "remove all":
                        app.RemoveAll();
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Incorrect input! Please enter valid commnd.\n");
                    WriteHelp();
                }
            } while (commandText != "exit");
        }
Пример #2
0
        internal void Run()
        {
            var app = new TodoApp();

            app.List();

            string commandText;

            do
            {
                Console.Write(">");
                commandText = Console.ReadLine().ToLower().Trim();

                if (commandText == "help")
                {
                    WriteHelp();
                }
                else if (commandText == "list")
                {
                    app.List();
                }
                else if (commandText == "add")
                {
                    app.Add();
                }
                else if (commandText == "done")
                {
                    app.SetDone();
                }
                else if (commandText == "remove")
                {
                    app.Remove();
                }
                else if (commandText == "undone")
                {
                    app.SetUndone();
                }
                else if (commandText == "removeall")
                {
                    app.RemoveAll();
                }
                // Code review: This message get's displayed when exit commend is issued. That was a bug. This is fix.

                // This should be last command check.
                else if (commandText != "exit")
                {
                    Console.WriteLine("Unknown message has been entered!");
                    WriteHelp();
                }
            } while (commandText != "exit");
        }
Пример #3
0
        internal void Run()
        {
            var app = new TodoApp();

            app.List();

            string command;

            do
            {
                Console.Write(">");
                var commandText = Console.ReadLine();
                command = TodoCommands.ParseCommand(commandText);

                if (command == TodoCommands.HELP)
                {
                    WriteHelp();
                }
                else if (command == TodoCommands.LIST)
                {
                    app.List();
                }
                else if (command == TodoCommands.ADD)
                {
                    app.Add();
                }
                else if (command == TodoCommands.DONE)
                {
                    app.SetDone();
                }
                else if (command == TodoCommands.REMOVE)
                {
                    app.Remove();
                }
                else if (command == TodoCommands.INVALID)
                {
                    WriteInvalidCommandMessage();
                }
            } while (command != TodoCommands.EXIT);
        }