Пример #1
0
        public static void Choices()
        {
            //Welcome user to program with intructions
            Console.WriteLine("Coding challenge menu:");
            Console.WriteLine("Please select the program you want to run and press enter.");
            Console.WriteLine();//Space between outputs

            //Displays the menu choices
            Console.WriteLine("[1] Swap Name\r\n[2] Backwards\r\n[3] Age Convert\r\n[4] Temp Convert\r\n[5] Big Blue Fish\r\n[0] Exit");

            //User prompt for selection
            string userChoiceString = Console.ReadLine();

            //Variable to store user number input
            int userChoice;

            //Loop to verify user input
            while (!int.TryParse(userChoiceString, out userChoice) || (userChoice > 5) || (string.IsNullOrWhiteSpace(userChoiceString)))
            {
                Console.WriteLine("Please enter a valid option");
                userChoiceString = Console.ReadLine();
            }


            //The set of conditionals call the program to run that the user selects
            if (userChoiceString == "1")
            {
                SwapName.Names();
            }
            else if (userChoiceString == "2")
            {
                Backwards.Reverse();
            }
            else if (userChoiceString == "3")
            {
                AgeConverter.AgeConvert();
            }
            else if (userChoiceString == "4")
            {
                TempConverter.TempConvert();
            }
            else if (userChoiceString == "5")
            {
                BigBlueFish.BigFish();
            }
            else if (userChoiceString == "0")
            {
                Environment.Exit(0);//will close application if user selects option to do so
            }
        }
Пример #2
0
        //NAME: Alexander Rodriguez
        //DATE: 1808
        //COURSE: Project & Porfolio 1
        //SYNOPSIS: Menu that allows the user to select an option to run programs from the coding challenges

        //Create fucntion for Menu

        public static void ChMenu()
        {
            //Variable for user selection
            string strUserSel;
            int    userSel = 0;
            bool   valOpt  = false;

            //Welcome and header
            Console.WriteLine("");
            Console.WriteLine("Welcome to my Project Porfolio Coding Challenge");
            Console.WriteLine("");

            Console.WriteLine("PROJECT + PORFOLIO");
            Console.WriteLine("********************************************");
            Console.WriteLine("********************************************");
            Console.WriteLine("");

            //Show user menu
            Console.WriteLine("Coding Challenge Menu: \r\nPlease enter the number for the challenge you want to run...");
            Console.WriteLine("");

            Console.WriteLine("[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("");

            Console.WriteLine("[0] Exit");
            Console.WriteLine("");

            Console.WriteLine("********************************************");

            //Ask user to enter a selection
            Console.WriteLine("Make your selection:");
            strUserSel = Console.ReadLine();

            //Valitate user selection (number only)
            while (!int.TryParse(strUserSel, out userSel))
            {
                Console.WriteLine("Your have enter a invalid selection!\r\nPlease enter a valid selection from 1 - 5:");
                //Read user option
                strUserSel = Console.ReadLine();
            }

            //Valitate user selection (0 - 5)
            if (userSel > 5)
            {
                valOpt = false;
            }
            else
            {
                valOpt = true;
            }

            while (valOpt != true)
            {
                Console.WriteLine("Your selection is not valid!\r\nPlease enter a valid selection from 1 - 5:");
                //Read user option
                strUserSel = Console.ReadLine();
                int.TryParse(strUserSel, out userSel);

                if (userSel > 5)
                {
                    valOpt = false;
                }
                else
                {
                    valOpt = true;
                }
            }

            //Run Menu option depending on user selection

            //If selection is equal to 1 then run SwapName
            if (userSel == 1)
            {
                SwapName.ChSwapName();
            }

            //If selection is equal to 2 then run Backwards
            if (userSel == 2)
            {
                Backwards.ChBackwards();
            }

            //If selection is equal to 3 then run Age Convert
            if (userSel == 3)
            {
                AgeConvert.ChAgeConvert();
            }

            //If selection is equal to 4 then run TempConvert
            if (userSel == 4)
            {
                TempConvert.ChTempConvert();
            }

            //If selection is equal to 5 then run BigBlueFish
            if (userSel == 5)
            {
                BigBlueFish.ChBigBlueFish();
            }

            //If selection is equal to 0 then return to Menu
            if (userSel == 0)
            {
                Environment.Exit(0);
            }
        }
Пример #3
0
        public static void GetMenu()
        {
            while (true)
            {
                Console.Clear();
                Console.WriteLine("Menu");
                Console.WriteLine("Enter listed number choice");
                Console.WriteLine("");
                Console.WriteLine("[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("");
                Console.WriteLine("[0] Exit");
                Console.WriteLine("");
                Console.WriteLine("Enter your selected challenge");

                switch (GetMenu(menuChoice))
                {
                    case 1:
                        {
                            Console.Clear();
                            SwapName.GetSwapName();
                        }
                        break;
                    case 2:
                        {
                            Console.Clear();
                            Backwards.GetBackWards();
                        }
                        break;
                    case 3:
                        {
                            Console.Clear();
                            AgeConvert.GetAgeConvert();
                        }
                        break;
                    case 4:
                        {
                            Console.Clear();
                            TempConvert.GetTempConvert();
                        }
                        break;
                    case 5:
                        {
                            Console.Clear();
                            BigBlueFish.GetBigBlueFish();
                        }
                        break;
                    case 0:
                        {
                            if (menuChoice == 0)
                            {
                                Environment.Exit(0);
                            }
                        }
                        break;

                    default:
                        break;
                }
                
            }
        }