Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleMenu
- {
- class Program
- {
- static void Main(string[] args)
- {
- const string CommandReduceWindow = "reduceWinSize";
- const string CommandIncreaseWindow = "increaseWinSize";
- const string CommandInvertColors = "invertColors";
- const string CommandChangePassword = "changePassword";
- const string CommandClearScreen = "clear";
- const string CommandExit = "exit";
- string userCommand;
- string userInput;
- string password = "admin";
- int windowHeight = 16;
- int windowWidth = 96;
- bool isRunning = true;
- Console.SetWindowSize(windowWidth, windowHeight);
- Console.WriteLine($"Список команд: {CommandReduceWindow}, {CommandIncreaseWindow}, {CommandInvertColors}, {CommandChangePassword}, {CommandClearScreen}, {CommandExit}");
- Console.WriteLine($"Default password is \"{password}\"");
- while (isRunning)
- {
- userCommand = Console.ReadLine();
- switch (userCommand)
- {
- case CommandReduceWindow:
- windowHeight--;
- windowWidth--;
- Console.SetWindowSize(windowWidth, windowHeight);
- break;
- case CommandIncreaseWindow:
- windowHeight++;
- windowWidth++;
- Console.SetWindowSize(windowWidth, windowHeight);
- break;
- case CommandInvertColors:
- ConsoleColor consoleColor = Console.BackgroundColor;
- Console.BackgroundColor = Console.ForegroundColor;
- Console.ForegroundColor = consoleColor;
- break;
- case CommandChangePassword:
- Console.Write("Введите старый пароль: ");
- userInput = Console.ReadLine();
- if (userInput == password)
- {
- Console.Write("Введите новый пароль: ");
- password = Console.ReadLine();
- Console.WriteLine("Пароль успешно изменён.");
- }
- else
- {
- Console.WriteLine("Неверно введён пароль.");
- }
- break;
- case CommandClearScreen:
- Console.Clear();
- break;
- case CommandExit:
- isRunning = false;
- break;
- default:
- Console.WriteLine("Неизвестная команда.");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement