Esempio n. 1
0
 public static void UserSelction(string inputString)
 {
     if (inputString == "1")
     {
         Console.WriteLine("Opening Swap Name Coding Challenge");
         CE2_SwapName.SwapNameTest();
         //run CE2_SwapName
     }
     else if (inputString == "2")
     {
         Console.WriteLine("Opening Backwards Coding Challenge");
         //run CE3_Backwards
         CE3_Backwards.BackwardsTest();
     }
     else if (inputString == "3")
     {
         Console.WriteLine("Opening Age Convert Coding Challenge");
         //run CE4_AgeConvert
         CE4_AgeConvert.AgeConvertTest();
     }
     else if (inputString == "4")
     {
         Console.WriteLine("Opening Temp Convert Coding Challenge");
         //run CE5_TempConvert
         CE5_TempConvert.TempConvertTest();
     }
     else if (inputString == "5")
     {
         Console.WriteLine("Opening Big Blue Fish Coding Challenge");
         //run CE6_BigBlueFish
         CE6_BigBlueFish.BigBlueFishTest();
     }
     else if (inputString == "0")
     {
         Console.WriteLine("Closing Coding Challenge");
         //terminate program
     }
     else
     {
         //invalid input. re-Ask
         Console.WriteLine("Please Enter a valid number");
         inputString = Console.ReadLine();
         CE7_Validation.ValidateStringInput();
         UserSelction(inputString);
     }
 }
        //Create a New method that will display a menu and prompt the user to make a selection
        public static void MenuChoice()
        {
            //Display the selection choices to the user
            Console.WriteLine("\r\n(1) Swap Name");
            Console.WriteLine("(2) Backwards");
            Console.WriteLine("(3) Age Convert");
            Console.WriteLine("(4) Temp Convert");
            Console.WriteLine("(5) Big Blue Fish");
            Console.WriteLine("(0) EXIT");
            //Prompt the user to make a selection
            Console.WriteLine("\r\nChoose your selection: ");
            string userInput = Console.ReadLine();

            // Make sure the user is entering a valid selection
            bool choice = int.TryParse(userInput, out int selection);

            //Create a while loop to ensure the user is entering a number between 0-5 only
            while (choice == false || selection > 5 || selection < 0)

            {    //Tell the user that they've made a mistake
                Console.WriteLine("You entered an invalid selection. Please enter a number that corresponds to a selection above.");
                //Store the users new input
                userInput = Console.ReadLine();
                //Validate the users new input
                choice = int.TryParse(userInput, out selection);
            }

            // Confirm to the user the selection they entered
            Console.WriteLine("You have entered Challenge #{0}.", selection);

            //Begin switch statement that runs the class challenge the user selected
            switch (selection)
            {
            case 1:
                Console.WriteLine("The Swap Name Challenge, will now run.\r\n");
                CE2___SwapName.SwapName();
                //Display the menu again after the selection runs
                CE1_Menu.MenuChoice();
                break;

            case 2:
                Console.WriteLine("The Backwards Challenge, will now run.\r\n");
                CE3_Backwards.BackwardsGame();
                //Display the menu again after the selection runs
                CE1_Menu.MenuChoice();

                break;

            case 3:
                Console.WriteLine("The Age Convert Challenge, will now run.\r\n");
                CE4_AgeConvert.AgeConvert();
                //Display the menu again after the selection runs
                CE1_Menu.MenuChoice();
                break;

            case 4:
                Console.WriteLine("The Temp CpnvertChallenge, will now run.\r\n");
                CE5_TempConvert.TempConvert();
                //Display the menu again after the selection runs
                CE1_Menu.MenuChoice();
                break;

            case 5:
                Console.WriteLine("The Big Blue Fish Challenge, will now run.\r\n");
                CE6_BigBlueFish.BigBlueFish();
                //Display the menu again after the selection runs
                CE1_Menu.MenuChoice();
                break;

            case 0:
                Console.WriteLine("You will now return to the main menu.\r\n");
                CE1_Menu.MenuChoice();
                break;

            default:
                Console.WriteLine("Please enter a valid selection from the above menu.");
                break;


                //Outputs based on user selection
            }
        }