Advertisement
rukvir

HW 2_6_2

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