Advertisement
growhack

Tack with app

Mar 30th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TaskWithApp
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string setName;
  10.             string changeConsoleColor;
  11.             string setPasssword;
  12.             string password;
  13.             int tryPassCount;
  14.             string exit = " ";
  15.             while (exit != "Esc")
  16.             {
  17.                 tryPassCount = 3;
  18.                 Console.Write("Назовите себя: ");
  19.                 setName = Console.ReadLine();
  20.                 Console.Write("Установите пароль:");
  21.                 setPasssword = Console.ReadLine();
  22.                 password = setPasssword;
  23.                 while (tryPassCount-- > 0)
  24.                 {
  25.                     Console.Write("Введите пароль: ");
  26.                     password = Console.ReadLine();
  27.                     if(password == setPasssword)
  28.                     {
  29.                         Console.WriteLine("Знаешь что, " + setName + " ?");
  30.                         Console.WriteLine("Ты большой молодец!");
  31.                         break;
  32.                     }
  33.                     else if(tryPassCount == 0)
  34.                     {
  35.                         Console.WriteLine("Попытки кончились, увы дружок");
  36.                     }
  37.                     else
  38.                     {
  39.                         Console.WriteLine("Знаешь, пароль не верен - Попробуй ещё раз ");
  40.                     }
  41.                 }              
  42.                 Console.WriteLine("Какой цвет текста вы хотите установить? \n Красный \n Зеленый \n Синий \n Желтый \n Нажмите Enter - чтобы установить цвет текста белого цвета");
  43.                 changeConsoleColor =  Console.ReadLine().ToLower();
  44.                 Console.ForegroundColor = changeConsoleColor switch
  45.                 {
  46.                     "красный" => ConsoleColor.Red,
  47.                     "зеленый" => ConsoleColor.Green,
  48.                     "синий" => ConsoleColor.Blue,
  49.                     "желтый" => ConsoleColor.DarkYellow,
  50.                     _ => ConsoleColor.White,
  51.                 };
  52.                 Console.Write("Если вы хотите закончить программу напишите Esc :");
  53.                 exit = Console.ReadLine();
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement