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 ConsoleMenu
- {
- class Program
- {
- static void Main(string[] args)
- {
- string userCommand;
- int winHeight = 16;
- int winWidth = 96;
- bool backgroundIsBlack = true;
- string password = "admin";
- Console.SetWindowSize(winWidth, winHeight);
- Console.WriteLine("Список команд: reduceWinSize, increaseWinSize, invertColors, changePassword, clear, esc");
- Console.WriteLine($"Default password is {password}");
- string userInput;
- while (true)
- {
- userCommand = Console.ReadLine();
- switch (userCommand)
- {
- case "reduceWinSize":
- winHeight--;
- winWidth--;
- Console.SetWindowSize(winWidth, winHeight);
- break;
- case "increaseWinSize":
- winHeight++;
- winWidth++;
- Console.SetWindowSize(winWidth, winHeight);
- break;
- case "invertColors":
- backgroundIsBlack = !backgroundIsBlack;
- if (backgroundIsBlack)
- {
- Console.BackgroundColor = ConsoleColor.Black;
- Console.ForegroundColor = ConsoleColor.White;
- }
- else
- {
- Console.BackgroundColor = ConsoleColor.White;
- Console.ForegroundColor = ConsoleColor.Black;
- }
- break;
- case "changePassword":
- Console.Write("Введите старый пароль: ");
- userInput = Console.ReadLine();
- if(userInput == password)
- {
- Console.Write("Введите новый пароль: ");
- password = Console.ReadLine();
- Console.WriteLine("Пароль успешно изменён.");
- }
- else
- {
- Console.WriteLine("Неверно введён пароль.");
- }
- break;
- case "clear":
- Console.Clear();
- break;
- case "esc":
- return;
- default:
- Console.WriteLine("Неизвестная команда.");
- break;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment