Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int userInput = 0;
- int leftBorderRand;
- int rightBorderRand;
- int countOutput;
- int randomNumber;
- int diceGame;
- int playerNumber;
- int computerNumber;
- Random rand = new Random();
- while (userInput != 5 )
- {
- Console.WriteLine("Приветствуем вас в нашем меню");
- Console.WriteLine("1 - Получить случайное число ");
- Console.WriteLine("2 - Поменять текст на зеленый");
- Console.WriteLine("3 - Вывод слово МЕНЮ заданное количество раз в консоль");
- Console.WriteLine("4 - Игра в кубики");
- Console.WriteLine("5 - Выход");
- userInput = Convert.ToInt32(Console.ReadLine());
- switch(userInput)
- {
- case 1:
- Console.Write("Введите диапазон чисел.\nЛевая граница:");
- leftBorderRand = Convert.ToInt32(Console.ReadLine());
- Console.Write("Правая граница:");
- rightBorderRand = Convert.ToInt32(Console.ReadLine());
- if (rightBorderRand < leftBorderRand)
- {
- Console.WriteLine("Левая граница должна быть меньше правой.\n");
- }
- else
- {
- randomNumber = rand.Next(leftBorderRand, rightBorderRand + 1);
- Console.WriteLine($"Случайное число - {randomNumber}");
- }
- break;
- case 2:
- Console.ForegroundColor = ConsoleColor.Green;
- break;
- case 3:
- Console.Write("Сколько раз вывести слово МЕНЮ: ");
- countOutput = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < countOutput; i++)
- {
- Console.WriteLine("МЕНЮ");
- }
- break;
- case 4:
- Console.WriteLine("Правила игры:\nВы и компьютер бросаете куб, у кого больше, тот и победил.\nЕсли хотите сыграть введите 1, для выхода любой другой ввод");
- diceGame = Convert.ToInt32(Console.ReadLine());
- if (diceGame == 1)
- {
- playerNumber = rand.Next(1,7);
- computerNumber = rand.Next(1,7);
- Console.WriteLine($"Ваше число - {playerNumber}");
- Console.WriteLine($"Число компьютера - {computerNumber}");
- if (playerNumber > computerNumber)
- {
- Console.WriteLine("Вы победили!\n");
- }
- else if (computerNumber > playerNumber)
- {
- Console.WriteLine("Вы проиграли!\n");
- }
- else
- {
- Console.WriteLine("Ничья!\n");
- }
- }
- break;
- case 5:
- break;
- default:
- Console.WriteLine("Некорректный ввод!\n");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement