Advertisement
Rodunskiy

Untitled

May 2nd, 2023
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.91 KB | None | 0 0
  1. const string CommandName = "1";
  2. const string CommandSurname = "2";
  3. const string CommandAge = "3";
  4. const string CommandLogin = "4";
  5. const string CommandPassword = "5";
  6. const string CommandChangeTextColor = "6";
  7. const string CommandChangeConsoleColor = "7";
  8. const string CommandExit = "8";
  9.  
  10. int changeTextColor;
  11. bool canExit = true;
  12. string userInput;
  13. int colorRed = 1;
  14. int colorBlue = 2;
  15.  
  16. while (canExit)
  17. {
  18.     Console.Clear();
  19.     Console.WriteLine($"Выберите нужную команду:\n {CommandName} <-- Ввести имя.\n {CommandSurname} <-- Ввести фамилию.\n {CommandAge} <-- Ввести возраст.\n {CommandLogin} <-- Ввести логин.\n {CommandPassword} <-- Ввести пароль.\n {CommandChangeTextColor} <-- Поменять цвет текста.\n {CommandChangeConsoleColor} <-- Поменять цвет консоли.\n {CommandExit} <-- Выйти из программы.");
  20.     userInput = Console.ReadLine();
  21.  
  22.     switch (userInput)
  23.     {
  24.         case CommandName:
  25.             Console.WriteLine("Введите имя:");
  26.             string name = Console.ReadLine();
  27.             break;
  28.  
  29.         case CommandSurname:
  30.             Console.WriteLine("Введите фамилию:");
  31.             string surname = Console.ReadLine();
  32.             break;
  33.  
  34.         case CommandAge:
  35.             Console.WriteLine("Введите возраст:");
  36.             string age = Console.ReadLine();
  37.             break;
  38.  
  39.         case CommandLogin:
  40.             Console.WriteLine("Введите логин");
  41.             string login = Console.ReadLine();
  42.             break;
  43.  
  44.         case CommandPassword:
  45.             Console.WriteLine("Введите пароль");
  46.             string password = Console.ReadLine();
  47.             break;
  48.  
  49.         case CommandChangeTextColor:
  50.             Console.WriteLine("Выберете цвет текста:\n 1 <-- красный.\n 2 <-- синий");
  51.             changeTextColor = Convert.ToInt32(Console.ReadLine());
  52.  
  53.             if (changeTextColor == colorRed)
  54.             {
  55.                 Console.ForegroundColor = ConsoleColor.Red;
  56.             }
  57.             else if (changeTextColor == colorBlue)
  58.             {
  59.                 Console.ForegroundColor = ConsoleColor.Blue;
  60.             }
  61.             break;
  62.  
  63.         case CommandChangeConsoleColor:
  64.             Console.WriteLine("Выберете цвет консоли:\n 1 <-- красный.\n 2 <-- синий");
  65.             changeTextColor = Convert.ToInt32(Console.ReadLine());
  66.  
  67.             if (changeTextColor == colorRed)
  68.             {
  69.                 Console.BackgroundColor = ConsoleColor.Red;
  70.             }
  71.             else if (changeTextColor == colorBlue)
  72.             {
  73.                 Console.BackgroundColor = ConsoleColor.Blue;
  74.             }
  75.             break;
  76.  
  77.         case CommandExit:
  78.             canExit = false;
  79.             break;
  80.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement