Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CSLight
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- const string CommandShowText = "1";
- const string CommandShowRandomNumber = "2";
- const string CommandClearConsole = "3";
- const string CommandExit = "4";
- bool isRunning = true;
- Random random = new Random();
- while (isRunning)
- {
- Console.WriteLine("Введите команду: " +
- $"\n {CommandShowText} - Вывести текст" +
- $"\n {CommandShowRandomNumber} - Показать случайное число" +
- $"\n {CommandClearConsole} - Очистить консоль" +
- $"\n {CommandExit} - Выйти");
- string userInput = Console.ReadLine();
- switch (userInput)
- {
- case CommandShowText:
- Console.WriteLine("Какой текст вывести?");
- string textToShow = Console.ReadLine();
- Console.WriteLine(textToShow);
- break;
- case CommandShowRandomNumber:
- Console.WriteLine("Введите минимальное значение:");
- int minValue = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите максимальное значение:");
- int maxValue = Convert.ToInt32(Console.ReadLine());
- if (minValue < maxValue)
- {
- int randomNumber = random.Next(minValue, maxValue + 1);
- Console.WriteLine($"Ваше случайное число: {randomNumber}");
- }
- else
- {
- Console.WriteLine("Минимальное число не может быть больше максимального");
- }
- break;
- case CommandClearConsole:
- Console.Clear();
- Console.WriteLine("Консоль очишена");
- break;
- case CommandExit:
- isRunning = false;
- break;
- default:
- Console.WriteLine("Неизвестная команада");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement