Beispiel #1
0
        /// <summary>
        /// Processes the users input and outputs the data to the console
        /// </summary>
        /// <returns>true if ran properly</returns>
        public bool ProcessUserSelection()
        {
            InsertionSort sort = new InsertionSort(Employees);

            Console.Title = "Employee Program";
            Console.WriteLine("EMPLOYEE PROGRAM");
            Console.WriteLine("Created by, Noah Tomkins - 000790079");
            Console.WriteLine("\nSelect Employees and manage employees pay and hours\n\n");

            DisplayMenu();

            while (true)
            {
                string input = Console.ReadLine();
                Console.Clear();
                if ((int.TryParse(input, out int userSelection) == false) || userSelection < 1 || userSelection > 6)
                {
                    Console.WriteLine("\nInput invalid. Please enter a value between 1 and 6.");
                    continue;
                }

                if (userSelection == 1)
                {
                    sort.ByName();
                }
                else if (userSelection == 2)
                {
                    sort.ByNumber();
                }
                else if (userSelection == 3)
                {
                    sort.ByRate();
                }
                else if (userSelection == 4)
                {
                    sort.ByHours();
                }
                else if (userSelection == 5)
                {
                    sort.ByGross();
                }
                else //userSelection must be 6, so exit
                {
                    break;
                }

                Console.WriteLine("\n\n");
                DisplayMenu();
            }


            return(true);
        }