Пример #1
0
        /// <summary>
        ///
        /// </summary>
        public void RunApp()
        {
            do
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Title           = TITLE;
                PrintMenu();

                switch (DecisionsAndFormattingProgram.GetUserInput())
                {
                case 1:
                    //Get a new User name
                    GetUserName();
                    break;

                case 2:
                    //Display current name
                    DisplayName();
                    break;

                case 3:
                    //Exit
                    isTrue = false;
                    break;

                default:
                    //Invalid input
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Invalid input! Please re-enter.");
                    Thread.Sleep(1000);
                    break;
                }
            }while (isTrue);
        }
        /// <summary>
        ///
        /// </summary>
        private void RunApp()
        {
            isTrue = true;

            do
            {
                PrintMenu();

                switch (DecisionsAndFormattingProgram.GetUserInput())
                {
                case 1:

                    break;

                case 2:

                    break;

                case 3:

                    break;

                case 4:

                    break;

                case 5:

                    break;

                case 6:

                    break;

                case 7:

                    break;

                case 8:

                    break;

                case 9:

                    break;

                case 10:
                    //Exit
                    isTrue = false;
                    break;

                default:
                    //Invalid input
                    Console.WriteLine("Invalid input! Please re-enter.");
                    Console.Beep();
                    Thread.Sleep(1000);
                    break;
                }
            }while (isTrue);
        }
        /// <summary>
        ///
        /// </summary>
        public void PlayTheGame()
        {
            Console.Clear();
            Console.WriteLine($"\nHello {DecisionsAndFormattingProgram.GetName()}. Let's play the game!");
            Console.WriteLine($"Try to guess a number between {MIN} and {MAX - 1}.");

            isTrue = false;
            int number = GetRandomNumber();

            attempts = 0;

            do
            {
                Console.ForegroundColor = ConsoleColor.Green;
                attempts++;
                userInput = DecisionsAndFormattingProgram.GetUserInput();
                if (number == userInput)
                {
                    Console.Write($"\nThat is correct answer. It took you {attempts} ");
                    Console.Write((attempts > 1) ? "times." : "time.");
                    Console.WriteLine("\nPlease press ENTER to continue...");
                    Console.ReadLine();
                    isTrue = true;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Wrong, please try again.");
                }
            }while (!isTrue);
        }