Advertisement
Suslick

Task 6

Jan 5th, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 KB | None | 0 0
  1.  class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             string textCommands = "Команды!!\n" +
  6.                 "Показать команды: \'1\'\n" +
  7.                 "Пополнить баланс: \'2\'\n" +
  8.                 "Заказать еду: \'3\'\n" +
  9.                 "Проверить баланс: \'4\'\n" +
  10.                 "Сменить пароль: \'5\'\n" +
  11.                 "Очистить консоль: \'6\'\n" +
  12.                 "Выйти: \'7\'";
  13.             string userInput = "";
  14.             int balance = 100;
  15.             string password = "qwerty";
  16.             int priceDelivery = 20;
  17.             bool isExit = false;
  18.  
  19.             Console.WriteLine(textCommands);
  20.  
  21.             while (!isExit)
  22.             {
  23.                 Console.WriteLine("Введите команду: ");
  24.                 userInput = Console.ReadLine();
  25.  
  26.                 switch (userInput)
  27.                 {
  28.                     case "1":
  29.                         Console.WriteLine(textCommands);
  30.                         break;
  31.                     case "2":
  32.                         Console.WriteLine("Введите сумму");
  33.                         balance += Convert.ToInt32(Console.ReadLine());
  34.                         Console.WriteLine("Успешное пополние!!");
  35.                         break;
  36.                     case "3":
  37.                         Console.WriteLine($"Ваш курьер в пути. ( - {20}$)");
  38.                         balance -= priceDelivery;
  39.                         break;
  40.                     case "4":
  41.                         Console.WriteLine($"Ваш баланc - {balance}$");
  42.                         break;
  43.                     case "5":
  44.                         userInput = Console.ReadLine();
  45.                         if (userInput == password)
  46.                         {
  47.                             Console.WriteLine("Введите новый пароль");
  48.                             password = Console.ReadLine();
  49.                         }
  50.                         else
  51.                         {
  52.                             Console.WriteLine("Неверный пароль!!");
  53.                         }
  54.                         break;
  55.                     case "6":
  56.                         Console.Clear();
  57.                         break;
  58.                     case "7":
  59.                         isExit = true;
  60.                         break;
  61.                 }
  62.             }
  63.         }
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement