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 ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string commandInput = "";
- string userName = "User1";
- string userPassword = "";
- Console.WriteLine("Добро пожаловать. Введите команду. Для списка введите List");
- while (commandInput != "Exit")
- {
- Console.Write("Команда: ");
- commandInput = Console.ReadLine();
- switch (commandInput)
- {
- case "List":
- Console.WriteLine("Список команд:");
- Console.WriteLine("List - вывести список команд");
- Console.WriteLine("SetPass - установить/изменить пароль");
- Console.WriteLine("SetName - Задать/изменить имя пользователя");
- Console.WriteLine("WriteName - вывести текущее имя пользователя");
- Console.WriteLine("Clear - очистить окно консоли");
- Console.WriteLine("Exit - Выход из программы");
- break;
- case "SetPass":
- if (userPassword == "")
- {
- Console.Write("Установка пароля: ");
- string userPasswordInput1 = Console.ReadLine();
- Console.Write("Повторите пароль: ");
- string userPasswordInput2 = Console.ReadLine();
- if (userPasswordInput1 == userPasswordInput2)
- {
- Console.WriteLine("Пароль установлен");
- userPassword = userPasswordInput1;
- }
- else
- {
- Console.WriteLine("Пароли не совпадают. Пароль не установлен!");
- }
- }
- else
- {
- Console.Write("Для смены пароля введите текущий: ");
- string userPasswordInput1 = Console.ReadLine();
- string userPasswordInput2;
- if (userPassword == userPasswordInput1)
- {
- Console.Write("Установка пароля: ");
- userPasswordInput1 = Console.ReadLine();
- Console.Write("Повторите пароль: ");
- userPasswordInput2 = Console.ReadLine();
- if (userPasswordInput1 == userPasswordInput2)
- {
- Console.WriteLine("Пароль установлен");
- userPassword = userPasswordInput1;
- }
- else
- {
- Console.WriteLine("Пароли не совпадают. Пароль не установлен!");
- }
- }
- else
- {
- Console.WriteLine("Неверный пароль!");
- }
- }
- break;
- case "SetName":
- Console.Write("Для смены имени введите пароль: ");
- string userPasswordInput = Console.ReadLine();
- if (userPassword == userPasswordInput)
- {
- Console.Write("Введите новое имя: ");
- userName = Console.ReadLine();
- }
- else
- {
- Console.WriteLine("Неверный пароль!");
- }
- break;
- case "WriteName":
- Console.WriteLine(userName);
- break;
- case "Clear":
- Console.Clear();
- break;
- case "Exit":
- Console.WriteLine("Для закрытия окна нажмите любую клавишу");
- break;
- default:
- Console.WriteLine("Неизвестная команда");
- break;
- }
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment