Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- string userInput;
- string password;
- string name;
- string exit = "exit";
- int randomNumber;
- do
- {
- Console.WriteLine("------------------------------------------------");
- Console.WriteLine("Введите команду:\nChangeConsoleColor - Смена цвета консоли\nSetPassword - задть пароль\n" +
- "SetName - задать имя\nChangeTextColor - сменить цвет текста\nGetRandomNumber - получить случайное число\n" +
- "Esc - выход из программы");
- Console.Write("\nCommand: ");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "ChangeConsoleColor":
- Console.WriteLine("Выберите цвет: 1 - red | 2 - Green | 3 - Yellow | 4 - Blue");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "1":
- Console.BackgroundColor = ConsoleColor.Red;
- Console.Clear();
- break;
- case "2":
- Console.BackgroundColor = ConsoleColor.Green;
- Console.Clear();
- break;
- case "3":
- Console.BackgroundColor = ConsoleColor.Yellow;
- Console.Clear();
- break;
- case "4":
- Console.BackgroundColor = ConsoleColor.Blue;
- Console.Clear();
- break;
- }
- break;
- case "SetPassword":
- Console.WriteLine("Задайте пароль: ");
- password = Console.ReadLine();
- Console.WriteLine($"Вы установили пароль: {password}");
- break;
- case "SetName":
- Console.WriteLine("Задайте имя: ");
- name = Console.ReadLine();
- Console.WriteLine($"Вы задали имя: {name}");
- break;
- case "ChangeTextColor":
- Console.WriteLine("Выберите цвет: 1 - red | 2 - Green | 3 - Yellow | 4 - Blue");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "1":
- Console.ForegroundColor = ConsoleColor.Red;
- break;
- case "2":
- Console.ForegroundColor = ConsoleColor.Green;
- break;
- case "3":
- Console.ForegroundColor = ConsoleColor.Yellow;
- break;
- case "4":
- Console.ForegroundColor = ConsoleColor.Blue;
- break;
- }
- break;
- case "GetRandomNumber":
- Random rand = new Random();
- randomNumber = rand.Next(0, 101);
- Console.WriteLine($"Случайное число от 0 до 100: {randomNumber}");
- break;
- case "Esc":
- userInput = exit;
- break;
- default:
- if (userInput == exit)
- {
- break;
- }
- else
- {
- Console.WriteLine("Команда введена неверно.");
- }
- break;
- }
- }
- while (userInput != exit);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement