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 Homework_1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string userInput = "";
- string userName = "";
- string password = "";
- while (userInput != "Esc")
- {
- Console.Clear();
- Console.Write("Список команд\nSetName – установить имя\nChangeConsoleColor - изменить цвет консоли\nSetPassword – установить пароль" +
- "\nWriteName – вывести имя\nEsc – выход из программы\n\nВведите команду: ");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "SetName":
- if (userName == "")
- {
- Console.Write("Введите имя пользователя: ");
- userName = Console.ReadLine();
- Console.Write($"Теперь пользователя зовут {userName}.");
- Console.ReadKey();
- }
- else if (password == "")
- {
- Console.Write("Сначала задайте пароль!");
- Console.ReadKey();
- }
- else
- {
- Console.Write("Введите пароль: ");
- userInput = Console.ReadLine();
- if (userInput == password)
- {
- Console.Write("Введите новое имя пользователя: ");
- userName = Console.ReadLine();
- Console.Write($"Теперь пользователя зовут {userName}.");
- Console.ReadKey();
- }
- else
- {
- Console.Write("Неверный пароль!");
- Console.ReadKey();
- }
- }
- break;
- case "ChangeConsoleColor":
- Console.Write("Введите цвет (black, red, blue, magenta, green, gray): ");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "black":
- Console.BackgroundColor = ConsoleColor.Black;
- break;
- case "red":
- Console.BackgroundColor = ConsoleColor.DarkRed;
- break;
- case "blue":
- Console.BackgroundColor = ConsoleColor.DarkBlue;
- break;
- case "magenta":
- Console.BackgroundColor = ConsoleColor.DarkMagenta;
- break;
- case "green":
- Console.BackgroundColor = ConsoleColor.DarkGreen;
- break;
- case "gray":
- Console.BackgroundColor = ConsoleColor.DarkGray;
- break;
- }
- break;
- case "SetPassword":
- if(password == "")
- {
- Console.Write("Придумайте пароль: ");
- password = Console.ReadLine();
- Console.Write("Пароль установлен.");
- Console.ReadKey();
- }
- else
- {
- Console.Write("Введите существующий пароль: ");
- userInput = Console.ReadLine();
- if(userInput == password)
- {
- Console.Write("Придумайте новый пароль: ");
- userInput = Console.ReadLine();
- Console.Write("Пароль установлен.");
- Console.ReadKey();
- }
- else
- {
- Console.Write("Неверный пароль!");
- Console.ReadKey();
- }
- }
- break;
- case "WriteName":
- if (userName == "")
- {
- Console.Write("Сначала задайте имя!");
- Console.ReadKey();
- }
- else if (password == "")
- {
- Console.Write("Сначала задайте пароль!");
- Console.ReadKey();
- }
- else
- {
- Console.Write("Ведите пароль: ");
- userInput = Console.ReadLine();
- if (userInput == password)
- {
- Console.Write($"Имя пользователя: {userName}");
- Console.ReadKey();
- }
- else
- {
- Console.Write("Неверный пароль!");
- Console.ReadKey();
- }
- }
- break;
- case "Esc":
- break;
- default:
- Console.Write("Такой команды нет!");
- Console.ReadKey();
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment