Advertisement
Rodunskiy

Untitled

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