Advertisement
Rodunskiy

Untitled

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