Advertisement
bonumopus

menu

Apr 12th, 2020
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 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 menu
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string name = "noname";
  14.             string password = "qwerty";
  15.             string userInput = "";
  16.             Console.WriteLine("Приветствую вас в консольном меню. Подсказка выводится по команде Help.");
  17.  
  18.             while (userInput != "Esc")
  19.             {
  20.                 Console.Write("Введите команду: ");
  21.                 userInput = Console.ReadLine();
  22.                 switch (userInput)
  23.                 {
  24.                     case "SetName":
  25.                         Console.Write("Введите новое имя: ");
  26.                         name = Console.ReadLine();
  27.                         break;
  28.                     case "ChangeConsoleColor":
  29.                         Console.ForegroundColor = ConsoleColor.Green;
  30.                         break;
  31.                     case "SetPassword":
  32.                         Console.Write("Введите новый пароль: ");
  33.                         password = Console.ReadLine();
  34.                         break;
  35.                     case "WriteName":
  36.                         Console.Write("Чтобы увидеть имя введите пароль: ");
  37.                         userInput = Console.ReadLine();
  38.                         if (userInput == password)
  39.                         {
  40.                             Console.WriteLine(name);
  41.                         }
  42.                         else
  43.                         {
  44.                             Console.WriteLine("Неправельный пароль.");
  45.                         }
  46.                         break;
  47.                     case "Help":
  48.                         Console.WriteLine("SetName - установить имя.");
  49.                         Console.WriteLine("ChangeConsoleColor - поменять цвет консоли");
  50.                         Console.WriteLine("SetPassword - установить пароль.");
  51.                         Console.WriteLine("WriteName - вывести имя.");
  52.                         Console.WriteLine("Help - вывести подсказку.");
  53.                         Console.WriteLine("Esc - выйти из программы.");
  54.                         break;
  55.                 }
  56.             }
  57.             Console.WriteLine("Выход из программы. Пока, пока!");
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement