Ejemplo n.º 1
0
        /*
         * 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();
        }
Ejemplo n.º 2
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;
                }
            }
        }
Ejemplo n.º 3
0
        // Method for Challenge 2
        public static void ChallengeTwo()
        {
            Console.WriteLine("You are now entering Challenge 2!\r\n");
            // Initiate variable for validation and storing user input
            string userSentence;

            // Prompt user for a sentence, validate for blank space and that it has at least six words, then store
            Console.WriteLine("Please type in the sentense you would like to be reversed, six words minimum!");

            // Validate user input and ensure user types in at least 6 words
            userSentence = Validate.Input(Console.ReadLine(), "word", 6);

            // Create new Backwards object and pass in userSentence
            var userString = new Backwards(userSentence);

            // Give user feedback
            Console.WriteLine("You typed in : " + userString.Sentence);

            // Reverse string and give as new user feedback by calling the ReverseString method created in the Backwards class
            Console.WriteLine("Your sentence in reverse reads as: {0} \r\n", userString.ReverseString());
        }