ranee

Untitled

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