Advertisement
Guest User

2.3 + 2.5

a guest
Aug 26th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.57 KB | None | 0 0
  1. using System;
  2.  
  3. namespace lesson2
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string name = "";
  10.             string password = "123";
  11.             bool isAuthorized = false;
  12.             int tryCount = 3;
  13.             float money = 300;
  14.             string help = "GetName - Отобразить имя\nSetName - Установить имя\nВadge - Нарисовать бэйджик\nChangePassword - смена пароля\nTheme - цветовая тема меню\nСтандартный пароль 123";
  15.             string userInput = "";
  16.  
  17.             while(userInput != "exit") {
  18.                 Console.WriteLine("Добро пожаловать, в Личный кабинет\nВведите команду");
  19.                 userInput = Console.ReadLine();
  20.                 switch (userInput.ToLower())
  21.                 {
  22.                     case "getname":
  23.                         Console.Clear();
  24.                         if (name == "")
  25.                         {
  26.                             Console.WriteLine("Ваше имя на не известно, представтесь с помощью SetName");
  27.                         }
  28.                         else { Console.WriteLine("Ваше имя: " + name); }
  29.                         break;
  30.  
  31.                     case "setname":
  32.                         Console.Clear();
  33.                         if (!isAuthorized)
  34.                         {
  35.                             while (tryCount-- != 0)
  36.                             {
  37.                                 Console.WriteLine("Для смены имени введите пароль: ");
  38.                                 userInput = Console.ReadLine();
  39.                                 if(password == userInput)
  40.                                 {
  41.                                     isAuthorized = true;
  42.                                     Console.WriteLine("Введите ваше имя: ");
  43.                                     name = Console.ReadLine();
  44.                                     Console.WriteLine("Имя успешно изменено на " + name);
  45.                                     break;
  46.                                 }
  47.                                 else
  48.                                 {
  49.                                     Console.WriteLine("Неверный пароль, осталось" + tryCount + " попыток.");
  50.                                 }
  51.                             }
  52.                         }
  53.                         else {
  54.                             Console.WriteLine("Введите ваше имя: ");
  55.                             name = Console.ReadLine();
  56.                             Console.WriteLine("Имя успешно изменено на " + name);
  57.                         }
  58.                         break;
  59.  
  60.                     case "badge":
  61.                         Console.Clear();
  62.                         Console.WriteLine("Сейчас нарисуем вам бэйджик, какой символ хотите для рамки?");
  63.                         userInput = Console.ReadLine();
  64.                         if(name == "")
  65.                         {
  66.                             Console.WriteLine("Вы забыли представиться, используйте SetName");
  67.                         }
  68.                         else
  69.                         {
  70.                             Console.Write(userInput + userInput + userInput);
  71.                             for(int i = 0; i <= name.Length; i++)
  72.                             {
  73.                                 Console.Write(userInput);
  74.                             }
  75.                             Console.WriteLine(userInput + userInput );
  76.                             Console.WriteLine(userInput + "  " + name + "  " + userInput);
  77.                             Console.Write(userInput + userInput + userInput);
  78.                             for (int i = 0; i <= name.Length; i++)
  79.                             {
  80.                                 Console.Write(userInput);
  81.                             }
  82.                             Console.Write(userInput + userInput);
  83.                             Console.WriteLine();
  84.                            
  85.                         }
  86.                         break;
  87.  
  88.                     case "changepassword":
  89.                         Console.Clear();
  90.                         Console.WriteLine("Для сменны пароля введите старый пароль:");
  91.                         userInput = Console.ReadLine();
  92.                         while(tryCount-- != 0) {
  93.                             if (password == userInput)
  94.                             {
  95.                                 Console.WriteLine("Введите новый пароль:");
  96.                                 password = Console.ReadLine();
  97.                                 Console.WriteLine("Новый пароль установлен успешно!");
  98.                                 isAuthorized = false;
  99.                                 break;
  100.                             }
  101.                             else
  102.                             {
  103.                                 Console.WriteLine("Неверный пароль, у вас осталось " + tryCount + " попыток");
  104.                             }
  105.                         }
  106.                         break;
  107.  
  108.                     case "theme":
  109.                         Console.WriteLine("Настройка темы меню\nMatrix\nPony\nHard\nExit - что бы выйти");
  110.                         userInput = Console.ReadLine();
  111.                        
  112.                         switch (userInput.ToLower())
  113.                         {
  114.                             case "matrix":
  115.                                 Console.ForegroundColor = ConsoleColor.Green;
  116.                                 Console.BackgroundColor = ConsoleColor.Black;
  117.                                 Console.Clear();
  118.                                 break;
  119.  
  120.                             case "pony":
  121.                                 Console.ForegroundColor = ConsoleColor.Magenta;
  122.                                 Console.BackgroundColor = ConsoleColor.Cyan;
  123.                                 Console.Clear();
  124.                                 break;
  125.  
  126.                             case "hard":
  127.                                 Console.ForegroundColor = ConsoleColor.DarkBlue;
  128.                                 Console.BackgroundColor = ConsoleColor.Black;
  129.                                 Console.Clear();
  130.                                 break;
  131.  
  132.                             case "Exit":
  133.                                 break;
  134.  
  135.                             default:
  136.                                 Console.Clear();
  137.                                 Console.WriteLine("Нет такой темы! Ставим дефолтную :)");
  138.                                 Console.ResetColor();
  139.                                 break;
  140.                         }
  141.                         break;
  142.  
  143.                     case "?":
  144.                     case "help":
  145.                         Console.Clear();
  146.                         Console.WriteLine(help);
  147.                         break;
  148.  
  149.                     case "exit":
  150.                         Console.WriteLine("BB!");
  151.                         break;
  152.  
  153.                     default:
  154.                         Console.Clear();
  155.                         Console.WriteLine("Команда не распознана, для списка команд наберите Help или ?");
  156.                         break;
  157.                 }
  158.             }
  159.  
  160.         }
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement