Advertisement
pol9na

Untitled

Mar 2nd, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 KB | None | 0 0
  1. using System;
  2. namespace Сprogect
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             Console.WriteLine("Введите номер команды");
  9.             Console.WriteLine("1-сменить цвет консоли");
  10.             Console.WriteLine("2-сменить цвет фона текста");
  11.             Console.WriteLine("3-очистить консоль");
  12.             Console.WriteLine("4-установить имя");
  13.             Console.WriteLine("5-Установить пароль");
  14.             Console.WriteLine("6-вывести имя (после ввода пароля)");
  15.             Console.WriteLine("7-выход из программы");
  16.             int userChoice;
  17.             string name="Roman";
  18.             string password="1234";
  19.             string userPassword;
  20.             bool ESC = false;
  21.             while (ESC!=true) {
  22.                 userChoice = Convert.ToInt32(Console.ReadLine());
  23.                 switch (userChoice)
  24.                 {
  25.                     case 1:
  26.                         Console.ForegroundColor = ConsoleColor.Red;
  27.                         break;
  28.                     case 2:
  29.                         Console.BackgroundColor = ConsoleColor.Green;
  30.                         break;
  31.                     case 3:
  32.                         Console.Clear();
  33.                         break;
  34.                     case 4:
  35.                         Console.WriteLine("Введите новое имя");
  36.                         name = Console.ReadLine();
  37.                         break;
  38.                     case 5:
  39.                         Console.WriteLine("Введите новый пароль");
  40.                         password = Console.ReadLine();
  41.                         break;
  42.                     case 6:
  43.                         Console.WriteLine("Введите пароль");
  44.                         userPassword = Console.ReadLine();
  45.                         if (userPassword == password) {
  46.                             Console.WriteLine(name);
  47.                         }
  48.                         else
  49.                         {
  50.                             Console.WriteLine("Вы ввели неверный пароль");
  51.                         }
  52.                         break;
  53.                     case 7:
  54.                         ESC = true;
  55.                         break;
  56.                     default:
  57.                         Console.WriteLine("Выберите команду из списка");
  58.                         break;
  59.                 }
  60.                 }
  61.          }
  62.      }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement