ranee

Untitled

Jun 17th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Dynamic;
  5. using System.Linq;
  6. using System.Runtime.Serialization;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace CSLight
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             string comand;
  16.             string tempPassword = "";
  17.             string name = "";
  18.             string password = "";
  19.             int tryCount = 3;
  20.             string tempName;
  21.             while (true)
  22.             {
  23.                 comand = Console.ReadLine();
  24.                 if (comand == "Exit" || comand == "e")
  25.                 {
  26.                     break;
  27.                 }
  28.                 else if (comand == "Help" || comand == "h")
  29.                 {
  30.                     Console.WriteLine("Esc или e - выход из программы");
  31.                     Console.WriteLine("SetName или sn – установить имя");
  32.                     Console.WriteLine("ChangeConsoleColor или ссс - изменить цвет консоли");
  33.                     Console.WriteLine("SetPassword или sp – установить пароль ");
  34.                     Console.WriteLine("WriteName или wn– вывести имя (после ввода пароля)");
  35.                     Console.WriteLine("Help или h – отобразить список команд");
  36.                 }
  37.                 else if (comand == "SetName" || comand == "sn")
  38.                 {
  39.                     for (int i = 0; i < tryCount; i++)
  40.                     {
  41.                         Console.Write("Введите имя(не может содержать меньше одного символа):");
  42.                         tempName = Console.ReadLine();
  43.                         if (tempName.Length >= 1)
  44.                         {
  45.                             name = tempName;
  46.                             Console.WriteLine($"Имя '{name}' может быть использовано.");
  47.                             break;
  48.                         }
  49.                         else
  50.                         {
  51.                             Console.WriteLine("Имя должно содержать больше одного символа.");
  52.                         }            
  53.                     }
  54.                 }
  55.                 else if (comand == "SetPassword" || comand == "sp")
  56.                 {
  57.                     for (int i = 0; i < tryCount; i++)
  58.                     {
  59.                         Console.Write("Введите пароль(6 символов):");
  60.                         tempPassword = Console.ReadLine();
  61.                         if (tempPassword.Length >= 6)
  62.                         {
  63.                             password = tempPassword;
  64.                             Console.WriteLine($"Ваш пароль {password} отвечает требованиям.");
  65.                             break;
  66.                         }
  67.                         else
  68.                         {
  69.                             Console.WriteLine($"Ваш пароль {tempPassword} не отвечает требованиям. Требуется еще {6 - tempPassword.Length} cимволов");
  70.                         }
  71.                     }
  72.                 }
  73.                 else if (comand == "WriteName" || comand == "wn")
  74.                 {
  75.                     if (password == "" && name == "")
  76.                     {
  77.                        Console.WriteLine("Для отображения имени требуется задать пароль(Команда SetPassword) и имя (Команда SetName)");
  78.                         Console.WriteLine("");
  79.                         Console.WriteLine("");
  80.                     }
  81.                     else if (name == "")
  82.                     {
  83.                         Console.WriteLine("Для отображения требуется задать имя(Команда SetName)");
  84.                         Console.WriteLine("");
  85.                         Console.WriteLine("");
  86.                     }
  87.                     else if (password == "")
  88.                     {
  89.                         Console.WriteLine("Для отображения требуется задать пароль(Команда SetPassword)");
  90.                         Console.WriteLine("");
  91.                         Console.WriteLine("");
  92.                     }
  93.                     else if (name != "" && password != "")
  94.                         for (int i = 0; i < tryCount; i++)
  95.                         {
  96.                             Console.Write("Введите пароль:");
  97.                             if (password == Console.ReadLine())
  98.                             {
  99.                                 Console.WriteLine($"Ваше имя: {name}");
  100.                                 break;
  101.                             }
  102.                             else
  103.                             {
  104.                                 Console.WriteLine($"Пароль не верный, осталось {tryCount - i - 1} попыток");
  105.                             }
  106.                         }
  107.                 }
  108.                 else if (comand == "ChangeConsoleColor" || comand == "ccc")
  109.                 {
  110.                     while (true)
  111.                     {
  112.                         comand = Console.ReadLine();
  113.                         if (comand == "Exit" || comand == "e")
  114.                         {
  115.                             Console.WriteLine("Вы вышли из меню изменения цвета консоли.");
  116.                             break;
  117.                         }
  118.                         else if (comand == "ChangeBackgroundСolor" || comand == "cbc")
  119.                         {
  120.                             Console.WriteLine("Изменить на серый желтый - 1");
  121.                             Console.WriteLine("Изменить на серый красный - 2");
  122.                             Console.WriteLine("Изменить на серый зеленый - 3");
  123.                             comand = Console.ReadLine();
  124.                             switch (comand)
  125.                             {
  126.                                 case "1":
  127.                                     Console.BackgroundColor = ConsoleColor.Yellow;
  128.                                     Console.Clear();
  129.                                     Console.WriteLine("Цвет изменен на желтый");
  130.                                     break;
  131.                                 case "2":
  132.                                     Console.BackgroundColor = ConsoleColor.Red;
  133.                                     Console.Clear();
  134.                                     Console.WriteLine("Цвет изменен на красный");
  135.                                     break;
  136.                                 case "3":
  137.                                     Console.BackgroundColor = ConsoleColor.Green;
  138.                                     Console.Clear();
  139.                                     Console.WriteLine("Цвет изменен на зеленый");
  140.                                     break;
  141.                                 default:
  142.                                     Console.WriteLine("Такой команды не существует.");
  143.                                     Console.WriteLine("Вы вышли из меню изменения цвета фона консоли.");
  144.                                     break;
  145.                             }
  146.                         }
  147.                         else if (comand == "СhangeTextColor" || comand == "ctc")
  148.                         {
  149.                             Console.WriteLine("Изменить на серый белый - 1");
  150.                             Console.WriteLine("Изменить на серый черный - 2");
  151.                             Console.WriteLine("Изменить на серый синий - 3");
  152.                             comand = Console.ReadLine();
  153.                             switch (comand)
  154.                             {
  155.                                 case "1":
  156.                                     Console.ForegroundColor = ConsoleColor.White;
  157.                                     Console.Clear();
  158.                                     Console.WriteLine("Цвет изменен на белый");
  159.                                     break;
  160.                                 case "2":
  161.                                     Console.ForegroundColor = ConsoleColor.Black;
  162.                                     Console.Clear();
  163.                                     Console.WriteLine("Цвет изменен на черный");
  164.                                     break;
  165.                                 case "3":
  166.                                     Console.ForegroundColor = ConsoleColor.Blue;
  167.                                     Console.Clear();
  168.                                     Console.WriteLine("Цвет изменен на синий");
  169.                                     break;
  170.                                 default:
  171.                                     Console.WriteLine("Такой команды не существует.");
  172.                                     Console.WriteLine("Вы вышли из меню изменения цвета фона консоли.");
  173.                                     break;
  174.                             }
  175.                         }
  176.                         else if (comand == "Help" || comand == "h")
  177.                         {
  178.                             Console.WriteLine("Esc или e - выход из программы");
  179.                             Console.WriteLine("ChangeBackgroundСolor или cbc - изменить цвет фона");
  180.                             Console.WriteLine("СhangeTextColor или ctc - изменить цвет текста");
  181.                         }
  182.                         else if (comand != "ChangeBackgroundСolor" || comand != "cbc" || comand != "СhangeTextColor" || comand != "ctc" || comand != "Help" || comand != "h" || comand != "help")
  183.                         {
  184.                             Console.WriteLine($"Команды '{comand}'не существует, отобразить список команд - help");
  185.                         }
  186.                     }
  187.                 }    
  188.                         else if (comand != "SetName" || comand != "sn" || comand != "SetPassword" || comand != "sp" || comand != "WriteName" || comand != "wn" || comand != "Help" || comand != "h" || comand != "help")
  189.                         {
  190.                             Console.WriteLine($"Команды '{comand}'не существует, отобразить список команд - help");
  191.                         }
  192.             }
  193.         }
  194.     }
  195. }
Add Comment
Please, Sign In to add comment