ranee

Untitled

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