Advertisement
Montagne94

13. Консольное меню

Mar 25th, 2023 (edited)
836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.69 KB | None | 0 0
  1. namespace test
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             const string ExitCommand = "/Exit";
  8.             const string CommandChangePassword = "/ChangePassword";
  9.             const string CommandShowLogin = "/ShowLogin";
  10.             const string CommandShowPassword = "/ShowPassword";
  11.             const string CommandChangeNickname = "/ChangeNickname";
  12.  
  13.             string nickName = "User";
  14.             string password = "*****";
  15.             string inputUser = "";
  16.  
  17.             while (inputUser.ToUpper() != ExitCommand.ToUpper())
  18.             {
  19.                 Console.WriteLine("Для выбора пункта меню введите следующие каманды:\n");
  20.                 Console.WriteLine($"Изменить пароль - {CommandChangePassword}" +
  21.                     $"\nПоказать Логин - {CommandShowLogin} " +
  22.                     $"\nПоказать пароль - {CommandShowPassword}" +
  23.                     $"\nИзменить никнеим - {CommandChangeNickname}" +
  24.                     $"\nВыход из программы - {ExitCommand}\n");
  25.  
  26.                 inputUser = Console.ReadLine();
  27.                 Console.Clear();
  28.  
  29.                 switch (inputUser)
  30.                 {
  31.                     case CommandChangePassword:
  32.                         Console.WriteLine("Введите пароль");
  33.                         password = Console.ReadLine();
  34.                         Console.Clear();
  35.                         Console.WriteLine("Пароль успешно изменен");
  36.                         break;
  37.  
  38.                     case CommandShowLogin:
  39.                         Console.WriteLine($"Ваш никнейм {nickName}");
  40.                         break;
  41.  
  42.                     case CommandShowPassword:
  43.                         Console.WriteLine($"Ваш пароль {password}");
  44.                         break;
  45.  
  46.                     case CommandChangeNickname:
  47.                         Console.WriteLine("Введите никнем");
  48.                         nickName = Console.ReadLine();
  49.                         Console.Clear();
  50.                         Console.WriteLine("Никнейм успешно изменен");
  51.                         break;
  52.  
  53.                     case ExitCommand:
  54.                         Console.WriteLine("Programm Close... .");
  55.                         break;
  56.  
  57.                     default:
  58.                         Console.Clear();
  59.                         Console.WriteLine("Вы ввели не верную команду меню, попробуйте еще раз");
  60.                         break;
  61.                 }
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement