// Method for Challenge 3
        public static void ChallengeThree()
        {
            Console.WriteLine("You are now entering Challenge 3!\r\n");
            // Varibales used for name and age
            double age;
            string newName;

            // Prompt user for full name, validate, store, and create new name object with SwapInfo
            Console.Write("Please type in your full name: ");
            newName = Validate.Input(Console.ReadLine());
            var newUserName = new SwapInfo(newName);

            // Give user feedback
            Console.WriteLine("The name your entered is: " + newUserName.FullName);

            // Promt user for age, validate, store, and create new age object
            Console.Write("Please enter your age: ");
            age = Validate.Age(Console.ReadLine());
            var newAge = new AgeConvert(age);

            // Give user feedback and convert age to  other usable numbers
            Console.WriteLine("{0} has been alive for {1:n0} days!", newUserName.FullName, newAge.AgeDays());
            Console.WriteLine("{0} has been alive for {1:n0} hours!", newUserName.FullName, newAge.AgeHours());
            Console.WriteLine("{0} has been alive for {1:n0} minutes!", newUserName.FullName, newAge.AgeMin());
            Console.WriteLine("{0} has been alive for {1:n0} seconds!\r\n", newUserName.FullName, newAge.AgeSec());
        }
        /*
         * Name: Christopher Westman
         * Date(YYMM): 1801
         * Course:​ Project & Portfolio 1
         * Synopsis:​ This is a code challenge for Development. This challenge contains five sub-challenges.
         *          Every Challenge will be contained within its own class file.
         *          Each challenge solves a unique problem that must be solved. All challenges use the Validate class which
         *          contains several different types of validations. The validations can validate for word counts, single string inputs,
         *          and numbers within a certain range or above -1. This main program file is simplified to only show the calling of
         *          each challenge. To see the challenge code, simply open the class file with the name that mirrors the method call,
         *          for example, ChallengeOne can be found in the SwapInfo class file.
         */

        static void Main(string[] args)
        {
            // Challenge 1
            SwapInfo.ChallengeOne();

            // Challenge 2
            Backwards.ChallengeTwo();

            // Challenge 3
            AgeConvert.ChallengeThree();

            // Challenge 4
            TempConvert.ChallengeFour();

            // Challenge 5
            MainMenu.ChallengeFive();
        }
Beispiel #3
0
        // Method for Challenge 5
        public static void ChallengeFive()
        {
            Console.WriteLine("You are now entering Challenge 5!\r\n");
            // Use while loop to allow menu prompt
            while (true)
            {
                // Variable for user entry
                double entry;
                // Prompt user to select from menu
                Console.WriteLine("Which challenge would you like to try again?\r\n" +
                                  "Enter 1 for SwapInfo\r\n" +
                                  "Enter 2 for Backwards\r\n" +
                                  "Enter 3 for AgeConvert\r\n" +
                                  "Enter 4 for TempConvert\r\n" +
                                  "Or enter 0 to quit");
                // Validate and store user entry
                entry = Validate.Menu(Console.ReadLine());

                // Cycle through if statement to start user menu option
                if (entry == 1)
                {
                    SwapInfo.ChallengeOne();
                }
                else if (entry == 2)
                {
                    Backwards.ChallengeTwo();
                }
                else if (entry == 3)
                {
                    AgeConvert.ChallengeThree();
                }
                else if (entry == 4)
                {
                    TempConvert.ChallengeFour();
                }
                else if (entry == 0)
                {
                    // Break out of while loop if user doesn't want to run program
                    Console.WriteLine("Exiting now! Thanks for using the program!");
                    break;
                }
            }
        }