Advertisement
vovanhik_24

#13

Aug 22nd, 2023 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.97 KB | None | 0 0
  1.         static void Main(string[] args)
  2.         {
  3.             const string CommandExit = "exit";
  4.             const string CommandLogin = "login";
  5.             const string CommandPassword = "password";
  6.             const string CommandName = "name";
  7.             const string CommandAge = "age";
  8.             const string CommandInfo = "info";
  9.  
  10.             string inputMessage = "";
  11.             string setLogin = "";
  12.             string setPassword = "";
  13.             string setName = "";
  14.             int setAge = 0;
  15.             bool isWorking = true;
  16.             string commandList = "\n1)login\n2)password\n3)name\n4)age\n5)info\n6)exit\n";
  17.  
  18.             while (isWorking)
  19.             {
  20.                 Console.WriteLine(commandList);
  21.                 Console.Write("Введите команду: ");
  22.                 inputMessage = Console.ReadLine();
  23.  
  24.                 switch (inputMessage.ToLower())
  25.                 {
  26.                     case CommandLogin:
  27.                         Console.Write("Введите логин: ");
  28.                         setLogin = Console.ReadLine();
  29.                         Console.Clear();
  30.                         break;
  31.  
  32.                     case CommandPassword:
  33.                         Console.Write("Введите пароль: ");
  34.                         setPassword = Console.ReadLine();
  35.                         Console.Clear();
  36.                         break;
  37.  
  38.                     case CommandName:
  39.                         Console.Write("Введите имя: ");
  40.                         setName = Console.ReadLine();
  41.                         Console.Clear();
  42.                         break;
  43.  
  44.                     case CommandAge:
  45.                         Console.Write("Введите возраст: ");
  46.                         setAge = Convert.ToInt32(Console.ReadLine());
  47.                         Console.Clear();
  48.                         break;
  49.  
  50.                     case CommandInfo:
  51.                         Console.WriteLine("::::информация об аккаунте::::");
  52.                         Console.WriteLine($"Ваше имя: {setName}\nВаш логин: {setLogin}\nВаш возраст: " +
  53.                             $"{setAge}\nВаш пароль: {setPassword}\n");
  54.                         Console.Write("Нажмите 'Enter' чтобы вернутся в меню комманд");
  55.                         Console.ReadKey();
  56.                         Console.Clear();
  57.                         break;
  58.  
  59.                     case CommandExit:
  60.                         Console.WriteLine("Вы вышли!");
  61.                         isWorking = false;
  62.                         break;
  63.  
  64.                     default:
  65.                         Console.WriteLine($"Вы ввели: {inputMessage}, комманда не распознана! Нажмите 'Enter'");
  66.                         Console.ReadKey();
  67.                         Console.Clear();
  68.                         break;
  69.                 }
  70.             }
  71.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement