Exemplo n.º 1
0
        public static void Execute()
        {
            UiConsole.PrintLine("ЗАДАНИЕ 3");
            string fileName = "TaskThree.txt";

            using (StreamWriter streamWriter = new StreamWriter(fileName))
            {
                streamWriter.WriteLine("root");
                streamWriter.WriteLine("GeekBrains");
            }

            StrMass      strArray     = new StrMass(2, 4);
            StreamReader streamReader = new StreamReader(fileName);

            strArray.SetColumn(0, streamReader.ReadLine(), streamReader.ReadLine());
            streamReader.Close();

            var check = false;

            for (int i = 1; i < 4; i++)
            {
                UiConsole.PrintLine($"Попытка {i}");
                strArray.SetColumn(i, UiConsole.GetString("Введите логин: "), UiConsole.GetString("Введите пароль: "));
                if (strArray.CompareColumn(0, i))
                {
                    check = true;
                    break;
                }
            }
            UiConsole.PrintLine(check?"Вы вошли в систему.":"Доступ запрещен!");
            UiConsole.EndAndClear();
        }
Exemplo n.º 2
0
        public static void Game()
        {
            var questionNum = 5;

            int[]  number        = new int[questionNum];
            var    check         = false;
            var    num           = 0;
            var    count         = 0;
            string fileName      = "TrueLie.txt";
            var    questionCount = QuestionCount(fileName);

            if (questionCount >= questionNum)
            {
                UiConsole.PrintLine("Игра \"ВЕРЮ-НЕ ВЕРЮ!\"\nВам зададут три вопроса и вам надо ответить \"Верю\" или \"Не верю\". Проверим вашу эрудицию и интуицию!");
                StrMass question = new StrMass(fileName, questionCount, 2);
                Random  random   = new Random();
                for (int i = 0; i < questionNum; i++)
                {
                    do
                    {
                        check = false;
                        num   = random.Next(questionCount);
                        for (int j = 0; j < i + 1; j++)
                        {
                            if (num == number[j])
                            {
                                check = true;
                                break;
                            }
                        }
                    } while (check);
                    number[i] = num;
                    UiConsole.PrintLine($"Вопрос {i + 1}: {question[number[i], 0]}");
                    if (question[number[i], 1] == GetAnswer())
                    {
                        count++;
                    }
                }
                UiConsole.PrintLine($"Правильных ответов: { count}");
            }
            else
            {
                UiConsole.PrintLine("Программа знает слишком мало фактов. Сыграть не получится. ='(");
            }
        }