Пример #1
0
 public static bool NumbersCorrespond(UserNumbers userNumers, NumberGenerator generator)
 {
     for (int i = 0; i < NumberGenerator.amountNumbers; i++)
     {
         if (userNumers[i] != generator[i])
         {
             return(false);
         }
     }
     return(true);
 }
Пример #2
0
        static void Main(string[] args)
        {
            var generator = new NumberGenerator();
            var userNum   = new UserNumbers();

            UserUtil.StartUserEntering(userNum);
            if (UserUtil.NumbersCorrespond(userNum, generator))
            {
                Console.WriteLine("Congratulations, you guessed right!");
            }
            else
            {
                Console.Write("You did not guess. Generated numbers: ");
                generator.ShowGeneratedNumbers();
            }
            Console.ReadKey();
        }
Пример #3
0
 public static void StartUserEntering(UserNumbers user)
 {
     //int[] numbers = new int[6];
     Console.WriteLine("Enter " + NumberGenerator.amountNumbers + "numbers of the random number generator");
     for (int i = 0; i < NumberGenerator.amountNumbers; i++)
     {
         Console.Write("Input number" + (i + 1) + ": ");
         try
         {
             var userInput = Convert.ToInt32(Console.ReadLine());
             if (userInput > 0 && userInput < 10)
             {
                 user[i] = userInput;
             }
         }
         catch
         {
             Console.WriteLine("Wrong imput. Enter integer number from 1 to 9");
             i--;
         }
     }
 }