Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- namespace Lesson2
- {
- class Program
- {
- static void Main(string[] args)
- {
- const string Riddle = "\"Транспорт, который везет двух незнакомых соседей на восток без водителя за рулем\"";
- const string CorrectAnswer = "троллейбус";
- const string GiveUpWord = "сдаюсь";
- int maxAttempts = 3;
- int currentAttempt = 0;
- string userAnswer;
- Console.WriteLine($"Привет! Давай поиграем в игру? Я загадал загадку.\n" +
- $"Попробуй отгадать ее. Количество попыток {maxAttempts}.\n" +
- $"Загадка:\n" +
- $"{Riddle}");
- bool quite;
- do
- {
- Console.Write("Введи свой ответ: ");
- userAnswer = Console.ReadLine().ToLower();
- currentAttempt++;
- switch (userAnswer)
- {
- case CorrectAnswer:
- Console.WriteLine("Правильно!");
- quite = true;
- break;
- case GiveUpWord:
- Console.WriteLine($"Правильный ответ: {CorrectAnswer}.");
- quite = true;
- break;
- default:
- if (currentAttempt != maxAttempts)
- {
- Console.WriteLine("Подумай еще.");
- quite = false;
- }
- else
- {
- Console.WriteLine("Это была последняя попытка, и ты не угадал. Конец игре.");
- quite = true;
- }
- break;
- }
- } while (!quite);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement