Advertisement
rukvir

HW 2_6

Mar 27th, 2022
953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HomeWorck_2_6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             bool commandProgramm = true;
  14.             string userName, userPassword, checkPassword;
  15.             userName = userPassword = checkPassword = "";
  16.  
  17.             while (commandProgramm)
  18.             {
  19.                 Console.WriteLine("Введите команду \"/help\" - для ознакомления. ");
  20.                 string command = Console.ReadLine();
  21.                 switch (command)
  22.                 {
  23.                     case "/help":
  24.                         Console.WriteLine("/SetName – установить имя \n/ChangeConsoleColor - изменить цвет консоли " +
  25.                             "\n/SetPassword – установить пароль \n/WriteName – вывести имя (после ввода пароля) \n/Esc – выход из программы");
  26.                         break;
  27.                     case "/SetName ":
  28.                         Console.Write("Введите Ваше имя ");
  29.                         userName = Console.ReadLine();
  30.                         Console.WriteLine($"Ваше имя: {userName}");
  31.                         break;
  32.                     case "/ChangeConsoleColor":
  33.                         Console.ForegroundColor = ConsoleColor.Magenta;
  34.                         Console.BackgroundColor = ConsoleColor.Yellow;
  35.                         break;
  36.                     case "/SetPassword":
  37.                         Console.WriteLine("Установите свой пароль: ");
  38.                         userPassword = Console.ReadLine();
  39.                         Console.WriteLine("Пароль успешно установлен!");
  40.                         break;
  41.                     case "/WriteName":
  42.                         Console.Write("Чтобы узнать имя введите пароль: ");
  43.                         checkPassword = Console.ReadLine();
  44.                         if (checkPassword == userPassword)
  45.                             Console.WriteLine($"Имя пользователя: {userName}");
  46.                         else
  47.                             Console.WriteLine("Пароль неверный!");
  48.                         break;
  49.                     case "/Esc":
  50.                         commandProgramm = false;
  51.                         break;
  52.                     default:
  53.                         Console.WriteLine("Вы ввели неверную команду. Воспользуйтесь изучите команды(/help)");
  54.                         break;
  55.                 }
  56.             }
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement