Example #1
0
        static void Main(string[] args)
        {
            bool ExitLogic=true;
            bool ExitCycle = true, q = false;//буловські комірки для управляння циклами
            int x = 0;//кількість цифр
            int y = 0;//саме число

            Limit numbers = new Limit();
            //Ввод кількості цифр
            while (ExitCycle)
            {
                Console.WriteLine("\n\t\t\t Доброго времени суток");
                if (q)
                    Console.WriteLine("\n Ви ввели не верно поптробуйте ещо раз");
                Console.Write("\n Введите количество цифер в числе от 4 до 9: ");
                numbers.LimitNumbers(out x, out q);
                ExitCycle = q;
                if (q) Console.Clear();
            }

            //Ввод числа гравця
            ExitCycle = true;
            while (ExitCycle)
            {
                if (q)
                    Console.WriteLine("\n Ви ввели не верно поптробуйте ещо раз");
                Console.Write("\n Введите число из {0} цифр: ", x);
                numbers.LimitNumbers(out q, x, out y);
                ExitCycle = q;
            }

            //Створення массива цифр з числа Играка
            ArrayOfNumber number = new ArrayOfNumber();
            Console.WriteLine();
            int[] NumberPlayer = number.ArrayPlayer(x,y);

            //Створення массива цифр Компютера
            Random NumberRandom = new Random();
            int[] NumberPc = number.ArrayPc(x);

            //Параметри для логіки Пк
            int a = 0;//Комірка для цифри якої не буде в числі Іграка
            int[] Array1 = new int[10];
            int[] NumberPc1 = new int[x];
            int[] NumberPlayer1 = NumberPlayer;
            int[] Array3 = new int[x];
            int[] Array4 = new int[x];
            Logic Comparison = new Logic();

            //Ввод числа на угадування
            Console.WriteLine("\n\t\t\t Игра началась");
            Console.WriteLine("Чтоб начать игру ведите число из {0} цифр",x);
            Console.WriteLine("   Ходи гравця                                      Ходи ПК");
            int t = 0;//Бики
            int r = 0;//Корови
            int p=0;
            int u=0;
            bool Final=false;
            for (int i = 0; i < 45; i++)
            {

                ExitCycle = true;
                while (ExitCycle)
                {
                    if (q)
                        Console.WriteLine("\n Ви ввели не верно поптробуйте ещо раз");
                    Console.Write("Введите чило: ");
                    numbers.LimitNumbers(out q, x, out y);
                    ExitCycle = q;
                }

                //Перевoрення його в масів
                int[] ArrayForComparison = number.ArrayPlayer(x, y);

                t = 0;
                r = 0;

                //Порівння введеного масиву з масивом Пк
                Comparison.LogicPlayer(NumberPc, ArrayForComparison, x, out t, out r);
                Console.Write("  | " + t + " биков  " + r + " коров");
                if (t == x)
                {
                    Console.WriteLine("\n\n\t\t\t Ви виграли!!!");
                    break;
                }

                bool s=false;
            //Жалкі попитки зробить логіку Пк
                if (ExitLogic)
                  Comparison.LogicPC(x, NumberPlayer, i, ref NumberPc1, out ExitLogic, ref Final);

                else
                {

                    if (u != x-1)
                    {
                    go:
                        if (NumberPlayer[p] == 11)
                        {
                            p++; goto go;
                        }

                        Array4 = Comparison.LogicPC(x, NumberPc1, NumberPlayer, u, ref p, out t, Array3, Array4);
                        p++;

                        if (p >= x) { u++; p = 0; }

                        if (t == x) break;
                        for (int j = 0; j < x; j++)
                        {
                            if (Array4[j] != 0) NumberPlayer[j] = 11;
                        }
                    }
                    else
                    {
                        for (int j = 0; j < x; j++)
                        {
                            if (Array4[j] == 0) Array4[j]=NumberPc1[x-1];
                        }
                        Console.Write("          ");
                        for (int j = 0; j < x; j++)
                            Console.Write(Array4[j]);
                        Console.Write("  |  5  биков  0  коров");
                        Console.WriteLine("\n\n\t\t\t Компютер Виграв!!!");
                        Final = true;
                        break;
                    }
                }

                Console.WriteLine();
                if (Final == true)
                {
                    Console.WriteLine("\n\n\t\t\t Компютер Виграв!!!");
                    break;
                }
             }

             Console.ReadKey();
        }
Example #2
0
 static void Main(string[] args)
 {
     var x = new Logic();
     Console.WriteLine(x.Filter(10));
 }