/// <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);
        }
Beispiel #2
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>
        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);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        public void GetUserName()
        {
            Console.Clear();
            isTrue = true;
            string name = "";

            do
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Please enter your name:");
                name = Console.ReadLine().Trim();

                if (name == null || name == "")
                {
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Invalid name. Please re-enter.");
                    Thread.Sleep(1000);
                }
            }while (name == null || name == "");

            DecisionsAndFormattingProgram.SetName(name);
        }
 /// <summary>
 /// Start the new Game
 /// </summary>
 public void PlayTheGame()
 {
     Console.Clear();
     Console.WriteLine($"\nHello {DecisionsAndFormattingProgram.GetName()}. Let's do some formatting in C#!");
     RunApp();
 }
Beispiel #6
0
 /// <summary>
 ///
 /// </summary>
 private void DisplayName()
 {
     Console.WriteLine($"Your current name is: {DecisionsAndFormattingProgram.GetName()}");
     Console.WriteLine("\nPlease press ENTER to continue...");
     Console.ReadLine();
 }