Fox_McCloud77

CSLight_Console_Menu_HW

Feb 14th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CSLight_Console_Menu_HW
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.OutputEncoding = Encoding.UTF8;
  14.  
  15.             string userInput;
  16.             string wantToContinue;
  17.             string setName = string.Empty;
  18.             string setPassword = string.Empty;
  19.             string setPasswordCheck;
  20.             string colorChange = string.Empty;
  21.  
  22.             Console.WriteLine("Приветствую! Я - JARVIS. Могу я вам с чем нибудь помочь?\n");
  23.             Console.WriteLine("Вот что я могу для вас сделать:\n");
  24.  
  25.             Console.WriteLine("1 - установить имя пользователя.");
  26.             Console.WriteLine("2 - изменить цвет консоли.");
  27.             Console.WriteLine("3 - установить пароль.");
  28.             Console.WriteLine("4 - вывести имя.");
  29.             Console.WriteLine("5 - вывести все возможные команды.");
  30.             Console.WriteLine("6 - очистить историю сообщений.");
  31.             Console.WriteLine("7 - выход из программы.\n");
  32.  
  33.             Console.Write("Вы хотите продолжить (Yes/No): ");
  34.             wantToContinue = Console.ReadLine();
  35.  
  36.             if (wantToContinue == "No")
  37.             {
  38.                 Console.ForegroundColor = ConsoleColor.Green;
  39.                 Console.WriteLine("\nУдачи, сэр!");
  40.             }
  41.  
  42.             while (wantToContinue == "Yes")
  43.             {
  44.                 Console.Write("\nВведите команду для инициализации: ");
  45.                 userInput = Console.ReadLine();
  46.  
  47.                 if (userInput == "7")
  48.                 {
  49.                     Console.ForegroundColor = ConsoleColor.Green;
  50.                     Console.WriteLine("\nВсего хорошего!");
  51.                     break;
  52.                 }
  53.  
  54.                 switch (userInput)
  55.                 {
  56.                     case "1":
  57.                         Console.Write("\nВведите имя пользователя: ");
  58.                         setName = Console.ReadLine();
  59.                         Console.WriteLine("\nИмя пользователя задано успешно!");
  60.                         break;
  61.                     case "2":
  62.                         Console.Write("\nКакой цвет вы хотите установить (Red, Blue, White): ");
  63.                         colorChange = Console.ReadLine();
  64.  
  65.                         if (colorChange == "Red")
  66.                             Console.ForegroundColor = ConsoleColor.Red;
  67.                         else if (colorChange == "Blue")
  68.                             Console.ForegroundColor = ConsoleColor.Blue;
  69.                         else if (colorChange == "White")
  70.                             Console.ForegroundColor = ConsoleColor.White;
  71.  
  72.                         Console.WriteLine($"\nЦвет консоли изменен на - {colorChange}");
  73.                         break;
  74.                     case "3":
  75.                         Console.Write("\nВведите новый пароль: ");
  76.                         setPassword = Console.ReadLine();
  77.                         Console.WriteLine("\nНовый пароль установлен!");
  78.                         break;
  79.                     case "4":
  80.                         Console.Write("\nВведите пароль: ");
  81.                         setPasswordCheck = Console.ReadLine();
  82.  
  83.                         if (setPasswordCheck == setPassword)
  84.                             Console.WriteLine($"\nВаше имя - {setName}");
  85.                         else
  86.                             Console.WriteLine("\nНельзя выполнить операцию!");
  87.  
  88.                         break;
  89.                     case "5":
  90.                         Console.WriteLine("\n1 - установить имя пользователя.");
  91.                         Console.WriteLine("2 - изменить цвет консоли.");
  92.                         Console.WriteLine("3 - установить пароль.");
  93.                         Console.WriteLine("4 - вывести имя.");
  94.                         Console.WriteLine("5 - вывести все возможные команды.");
  95.                         Console.WriteLine("6 - очистить историю сообщений.");
  96.                         Console.WriteLine("7 - выход из программы.");
  97.                         break;
  98.                     case "6":
  99.                         Console.Clear();
  100.                         Console.WriteLine("\nИстория очищена!");
  101.                         break;
  102.                 }
  103.             }
  104.             Console.ReadKey();
  105.         }
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment