Last active
February 7, 2025 10:40
-
-
Save maxon-taxon691/e11d05a182a567e708e0dc69794c7c43 to your computer and use it in GitHub Desktop.
задание написание консольного меню
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace ConsoleApp1 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
const string ShowGreetingCommand = "1"; | |
const string ShowAboutCommand = "2"; | |
const string ShowRandomNumberCommand = "3"; | |
const string ClearConsoleCommand = "4"; | |
const string ExitCommand = "5"; | |
Random random = new Random(); | |
int lowerLimit = 0; | |
int upperLimit = 1000; | |
bool isRunning = true; | |
while (isRunning) | |
{ | |
Console.WriteLine("Выберите команду, которую хотите: \n"); | |
Console.WriteLine($"{ShowGreetingCommand}. Приветствие"); | |
Console.WriteLine($"{ShowAboutCommand}. О нас"); | |
Console.WriteLine($"{ShowRandomNumberCommand}. Показать рандомное число"); | |
Console.WriteLine($"{ClearConsoleCommand}. Очистить консоль"); | |
Console.WriteLine($"{ExitCommand}. Выход из программы\n"); | |
string commands = Console.ReadLine(); | |
switch (commands) | |
{ | |
case ShowGreetingCommand: | |
Console.WriteLine("Привет, красавчик, как жизнь? Надеюсь все хорошо, а у меня вот 21:52 сейчас, а у тебя?"); | |
string message = Console.ReadLine(); | |
Console.WriteLine($"Вау, круто. \n"); | |
break; | |
case ShowAboutCommand: | |
Console.WriteLine("Мы такая-то такая-то компания, занимаемся многими полезными вещами и прочее прочее\n"); | |
break; | |
case ShowRandomNumberCommand: | |
int randomNumber = random.Next(lowerLimit, upperLimit + 1); | |
Console.WriteLine($"{randomNumber} \n"); | |
break; | |
case ClearConsoleCommand: | |
Console.Clear(); | |
break; | |
case ExitCommand: | |
isRunning = false; | |
Console.WriteLine("Завершение программы"); | |
break; | |
default: | |
Console.WriteLine("Что это? Введи что-то другое \n"); | |
break; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment