Beispiel #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
            }
        }
Beispiel #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);
            }
        }
Beispiel #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;
                }
                
            }
        }
        static void Main(string[] args)
        {
            // Name: Kevin Fernandez-Gonzalez
            // Date: 1812
            // Course: Project & Portfolio 1
            // synopsis: This is my DVP1 Project, Here I will save individual projects during my course and make it one



            Console.WriteLine("Coding Challenge Menu: Please enter the number for the challenge you want to run... \r\n" +
                              "[1] Swap name \r\n" +
                              "[2] Backward \r\n" +
                              "[0} exit");

            string choice    = Console.ReadLine();
            int    intChoice = 0;


            do
            {
                while (!int.TryParse(choice, out intChoice) && (intChoice >= 6 || intChoice < 0) && string.IsNullOrEmpty(choice))
                {
                    Console.WriteLine("Please enter a number from the option menu \r\n \r\n" +
                                      "Coding Challenge Menu: Please enter the number for the challenge you want to run... \r\n" +
                                      "[1] Swap name \r\n" +
                                      "[2] Backward \r\n" +
                                      "[0} exit");
                    choice    = Console.ReadLine();
                    intChoice = int.Parse(choice);
                }
                if (intChoice == 1)
                {
                    // swap name code challenge.
                    SwapName swappingNames = new SwapName();

                    Console.WriteLine("To Begin please enter your first name..");
                    string name = Console.ReadLine();
                    name = swappingNames.ValidateName(name);

                    Console.WriteLine("Thank you {0}, now I will need your last name", name);
                    string lastName = Console.ReadLine();
                    lastName = swappingNames.ValidateName(lastName);

                    swappingNames.SetSwapName(name, lastName);
                }
                if (intChoice == 2)
                {
                    Backwards backwards = new Backwards();
                    Console.WriteLine("Welcome to Backwards: To begin, please enter a sentence containing at least 6 words...");

                    string sentence = Console.ReadLine();
                    while (!backwards.Validation(sentence))
                    {
                        Console.WriteLine("Please enter with atleast 6 words ");
                        sentence = Console.ReadLine();
                    }
                    backwards.SetBackwards(sentence);
                }
                if (intChoice == 0)
                {
                    Console.WriteLine("Bye now, Thanks for playing");
                }
                choice    = Console.ReadLine();
                intChoice = 0;
            } while (intChoice == 0);
        }