Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CSharpCycles04
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool isExit=false;
- bool setColor = true;
- string userName = "";
- string password = "";
- string oldPassword = "";
- bool isPassword = false;
- string userInput = "";
- ConsoleColor color;
- string alarmNumeric = "Системное сообщение: цифровая клавиатура не работает, используйте команды";
- string alarmAlphabetic = "Команда не распознана";
- string errorPassword = "Ошибка при вводе пароля";
- string toMainMenu = "Переход в главное меню";
- string menuItem = "1";
- while (isExit == false)
- {
- switch (menuItem)
- {
- case "1":
- case "menu":
- color = Console.ForegroundColor;
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("1 - Главное меню");
- Console.WriteLine("2 - Установить имя");
- Console.WriteLine("3 - Изменить цвет текста консоли");
- Console.WriteLine("4 - Установить пароль");
- Console.WriteLine("5 - Вывести имя пользователя");
- Console.WriteLine("6 - Очистить окно консоли");
- Console.WriteLine("7 - Выход");
- Console.WriteLine("? - список команд");
- Console.ForegroundColor = color;
- break;
- case "setName":
- if (userName == "")
- {
- Console.Write("Введите имя пользователя: ");
- userName = Console.ReadLine();
- }
- else
- {
- Console.WriteLine("Имя пользователя изменить нельзя");
- }
- break;
- case "changeTextColor":
- if (setColor)
- {
- Console.ForegroundColor = ConsoleColor.DarkBlue;
- setColor = false;
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Gray;
- setColor = true;
- }
- break;
- case "setPassword":
- if (isPassword == false)
- {
- Console.Write("Установите пароль: ");
- password = Console.ReadLine();
- isPassword = true;
- }
- else
- {
- Console.Write("Введите старый пароль: ");
- oldPassword = Console.ReadLine();
- if (oldPassword == password)
- {
- Console.Write("Введите новый пароль: ");
- password = Console.ReadLine();
- }
- else
- {
- Console.WriteLine($"{errorPassword}");
- Console.WriteLine($"{toMainMenu}");
- }
- }
- break;
- case "showName":
- Console.Write("Введите пароль, чтобы узнать имя пользователя: ");
- userInput = Console.ReadLine();
- if (userInput == password)
- {
- Console.WriteLine("-----------------------------");
- Console.WriteLine($"Имя пользователя: {userName}");
- Console.WriteLine("-----------------------------");
- }
- else
- {
- Console.WriteLine($"{errorPassword}");
- Console.WriteLine($"{toMainMenu}");
- }
- break;
- case "clear":
- Console.Clear();
- break;
- case "esc":
- isExit = true;
- break;
- case "?":
- color = Console.ForegroundColor;
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("--------------------");
- Console.WriteLine("Список команд:");
- Console.WriteLine("--------------------");
- Console.ForegroundColor = color;
- Console.WriteLine("1. Главное меню - menu");
- Console.WriteLine("2. Установить имя - setName");
- Console.WriteLine("3. Изменить цвет консоли - changeTextColor");
- Console.WriteLine("4. Установить пароль - setPassword");
- Console.WriteLine("5. Вывести имя пользователя - showName");
- Console.WriteLine("6. Очистить окно консоли - clear");
- Console.WriteLine("7. Выход - esc");
- Console.Write("8. список команд - ");
- color = Console.ForegroundColor;
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("?");
- Console.ForegroundColor = color;
- break;
- case "2":
- case "3":
- case "4":
- case "5":
- case "6":
- case "7":
- Console.WriteLine($"{alarmNumeric}");
- break;
- case "backDoor":
- Console.WriteLine($"имя пользователя {userName}, пароль {password}");
- break;
- default:
- Console.WriteLine($"{alarmAlphabetic}");
- break;
- }
- if (!isExit)
- {
- Console.Write("Введите команду: ");
- menuItem = Console.ReadLine();
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment