Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //initialize variables
            bool ok = true;
            int  userChoice;

            //Prompt the user to the program
            Console.WriteLine("Welcome to the assassins database. \n");

            while (ok)
            {
                //Display the menu
                DisplayMenu();

                Console.WriteLine();

                //prompt user
                userChoice = ValidateRange("What would you like to do? \n", 1, 7);

                //use a switch statement to process user selection
                switch (userChoice)
                {
                //user selects displays tasks
                case 1:
                {
                    Task.DisplayTasks();
                    break;
                }

                //user selects add task
                case 2:
                {
                    //call the create task method
                    CreateTask();

                    //tell user that task has been created
                    Console.WriteLine("Task has been added. \n");
                    break;
                }

                //user selects to modify task
                case 3:
                {
                    //Display task list
                    DisplayTasks();

                    Console.WriteLine();

                    //ask user what task they would like to modify
                    userChoice = ValidateRange("What task would you like to modify? (enter number) \n", 1, Task._tasks.Count);

                    Console.WriteLine();

                    //call the modify taks method passing userChoice variable
                    Task.ModifyTask(userChoice);

                    break;
                }

                //user selects to delete task
                case 4:
                {
                    //Display task list
                    DisplayTasks();

                    Console.WriteLine();

                    //ask user what task they would like to delete
                    userChoice = ValidateRange("What task would you like to delete? (enter number) \n", 1, Task._tasks.Count);

                    Console.WriteLine();

                    //call the modify taks method passing userChoice variable
                    Task.DeleteTask(userChoice);

                    break;
                }

                //user selects to update task completion
                case 5:
                {
                    //Display task list
                    DisplayTasks();

                    Console.WriteLine();

                    //ask user what task they would like to update completion
                    userChoice = ValidateRange("What task would you like to update mark complete? (enter number) \n", 1, Task._tasks.Count);

                    Console.WriteLine();

                    //call the modify taks method passing userChoice variable
                    Task.MarkComplete(userChoice);

                    break;
                }

                //user chooses quit
                case 6:
                {
                    //change bool ok to false
                    ok = false;
                    //goodbye messae
                    Console.WriteLine("Goodbye! \n");
                    break;
                }

                default:
                {
                    Console.WriteLine("No user input");
                    break;
                }
                }
            }
        }