Sininerebane

Untitled

Oct 31st, 2023
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.15 KB | Software | 0 0
  1. namespace Othertask
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             Console.OutputEncoding = Encoding.UTF8;
  8.             int userInput;
  9.             int setColor;
  10.  
  11.             string password;
  12.             string setName;
  13.             string setPassword = "123456";
  14.             bool appActive = true;
  15.  
  16.             while (appActive)
  17.            {
  18.                 Console.WriteLine("Выберите нужную команду");
  19.                 Console.WriteLine("\n 1- Установить имя. \n2- Изменить цвет консоли. \n3- Установить пароль. \n4- Вывести имя. \n5- Выход из программы");
  20.  
  21.                 userInput = Convert.ToInt32(Console.ReadLine());
  22.  
  23.                 switch (userInput)
  24.                 {
  25.  
  26.                     case 1:
  27.                         Console.Write("Установите имя:");
  28.                         setName = Console.ReadLine();
  29.                         Console.Clear();
  30.                         break;
  31.  
  32.                     case 2:
  33.                         Console.WriteLine("Вы собираетесь поменять цвет консоли.\n Выберете цвет");
  34.                         Console.Write("1: Красный. \n 2: Зеленный ");
  35.                         setColor = Convert.ToInt32(Console.ReadLine());
  36.  
  37.                         if (setColor == 1)
  38.                         {
  39.                             Console.ForegroundColor = ConsoleColor.Red;
  40.                             Console.Clear();
  41.                         }
  42.                         else if (setColor == 2)
  43.                         {
  44.                             Console.ForegroundColor = ConsoleColor.Green;
  45.                             Console.Clear();
  46.  
  47.                         }
  48.                         break;
  49.  
  50.                     case 3:
  51.                         Console.Write("Установите пароль:");
  52.                         setPassword = Console.ReadLine();
  53.                         Console.Clear();
  54.                         break;
  55.  
  56.                     case 4:
  57.                         Console.WriteLine("Если вы введете верный пароль вы сможете установить имя");
  58.                         Console.Write("Введите пароль: ");
  59.                         password = Console.ReadLine();
  60.  
  61.                         if (password == setPassword)
  62.                         {
  63.  
  64.                             Console.WriteLine("Введите ваше имя:");
  65.                             setName = Console.ReadLine();
  66.                             Console.WriteLine("Имя пользователя: " + setName);
  67.                         }
  68.  
  69.                         else
  70.                         {
  71.                             Console.WriteLine("Пароль неверный.");
  72.                         }
  73.                         break;
  74.  
  75.                     case 5:
  76.                         Console.WriteLine("Вы вышли из меню!");
  77.                         appActive = false;
  78.                         break;
  79.                 }
  80.             }
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment