Example #1
0
        // Entry Point Method
        static void Main(string[] args)
        {
            // START HERE
            AppInfo.GetAppInfo(); // Run GetAppInfo function.

            Greeting.GreetUser(); // Ask for users name and greet.

            while (true)
            {
                // Init correct number
                int correctNumber = CreateRandomNumber.GenerateRandomNumber(0, 10);

                // Init guess var
                int guess = 0;

                // Ask user for number
                Console.WriteLine("Guess a number between 1 and 10.");

                // While guess is not correct
                while (guess != correctNumber)
                {
                    // Get users input
                    string input = Console.ReadLine();

                    // Make sure it's a number
                    if (!int.TryParse(input, out guess))
                    {
                        // Print error message
                        ErrorMessage.GetErrorMessage();

                        // Keep going
                        continue;
                    }
                    // Cast to int and put in guess
                    guess = Int32.Parse(input);

                    // Match guess to correct number
                    if (guess != correctNumber)
                    {
                        // Change text color
                        Console.ForegroundColor = ConsoleColor.Red;

                        // Tell user it's the wrong number
                        Console.WriteLine("Wrong number, please try again.");

                        // Reset text color
                        Console.ResetColor();
                    }
                }
                // Output success message
                SuccessMessage.GetSuccesMessage();

                // Get answer
                string answer = Console.ReadLine().ToUpper();

                if (answer != "Y")
                {
                    return;
                }
            }
        }