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 Homework4
- {
- class Program
- {
- static void Main(string[] args)
- {
- string name = "";
- string password = "";
- string userInput;
- bool isActive = true;
- while (isActive == true)
- {
- Console.WriteLine("--Команды--\n|Установить имя|\n|Изменить цвет консоли|\n|Установить пароль|\n|Вывести имя (после ввода пароля)|\n|Выход из программы|");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "Установить имя":
- SetName(out name);
- break;
- case "Изменить цвет консоли":
- ChangeConsoleColor();
- break;
- case "Установить пароль":
- SetPassword(out password);
- break;
- case "Вывести имя":
- WriteName(password, name);
- break;
- case "Выход из программы":
- Esc();
- break;
- default:
- Console.WriteLine("Ошибка ввода...");
- break;
- }
- Console.ReadKey();
- Console.Clear();
- }
- }
- static void SetName(out string name)
- {
- name = Console.ReadLine();
- Console.WriteLine($"Имя изменено на {name}");
- }
- static void ChangeConsoleColor()
- {
- Console.WriteLine("Выберите цвет(Green, Red или Break)");
- string userColor = Console.ReadLine();
- switch (userColor)
- {
- case "Green":
- Console.ForegroundColor = ConsoleColor.Green;
- break;
- case "Red":
- Console.ForegroundColor = ConsoleColor.Red;
- break;
- case "Reset":
- Console.ForegroundColor = ConsoleColor.White;
- break;
- default:
- Console.WriteLine("Такого цвета нет!");
- break;
- }
- }
- static void SetPassword(out string password)
- {
- password = Console.ReadLine();
- Console.WriteLine($"Пароль изменен на {password}");
- }
- static void WriteName(string password, string name)
- {
- Console.WriteLine("Сначала введите пароль: ");
- if (password != "" && password != null)
- {
- if (Console.ReadLine() == password)
- Console.WriteLine(name);
- else
- Console.WriteLine("Неверный пароль!");
- }
- }
- static void Esc()
- {
- Environment.Exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment