Advertisement
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;
- using System.Drawing;
- namespace Csharp_light
- {
- class Program
- {
- static void Main(string[] args)
- {
- string userName = "", userLogin = "", userPassword = "",dbPassword = "";
- bool enter = false, exit = false;
- Console.WriteLine("Команды:\nSetName - установить имя\nSetLogin - дать логин\nSetPassword - дать пароль\nLogAll - вывести всю информацию\nChangeConsoleColor -изменить цвет консоли\nLogDB - вывести пароль в рамке\nEsc - завершить программу");
- while (!exit)
- {
- string option = Console.ReadLine();
- switch (option)
- {
- case "SetName":
- Console.Write("Введите ваше Имя:\nВас зовут ");
- userName = Console.ReadLine();
- break;
- case "SetLogin":
- Console.Write("Введите логин:\nВаш логин ");
- userLogin = Console.ReadLine();
- break;
- case "SetPassword":
- dbPassword = userPassword;
- Console.Write("Введите пароль:");
- while (!enter)
- {
- ConsoleKeyInfo charKey = Console.ReadKey(true);
- switch (charKey.Key)
- {
- case ConsoleKey.Enter:
- Console.Write('\n');
- enter = true;
- break;
- case ConsoleKey.Backspace:
- if (userPassword.Length != 0)
- {
- userPassword = userPassword.Remove(userPassword.Length - 1);
- Console.Write("\b \b");
- }
- break;
- default:
- userPassword += charKey.KeyChar;
- Console.Write("*");
- break;
- }
- }
- break;
- case "LogAll":
- if (userPassword.Length > 0)
- {
- Console.WriteLine("Вас зовут: " + userName + " ваш логин: " + userLogin);
- }
- else
- {
- Console.WriteLine("Вам нужно задать пароль");
- }
- break;
- case "ChangeConsoleColor":
- Console.WriteLine("Введите цвет: red, blue, white");
- string color = Console.ReadLine();
- switch (color)
- {
- case "red":
- Console.ForegroundColor = ConsoleColor.Red;
- break;
- case "blue":
- Console.ForegroundColor = ConsoleColor.Blue;
- break;
- case "white":
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- break;
- case "LogDB":
- if (userPassword == dbPassword)
- {
- Console.WriteLine("Установите пароль");
- }
- else
- {
- string line = "";
- for (int i = 0; i < userPassword.Length + 2; i++)
- {
- line += '#';
- }
- Console.WriteLine(line);
- Console.WriteLine("#" + userPassword + "#");
- Console.WriteLine(line);
- }
- break;
- case "Esc":
- exit = true;
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement