Advertisement
dxoraxs

Untitled

Apr 11th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2.  
  3. namespace homework
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             const string pass = "qwerty", secret = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
  10.             string Password = "";
  11.             for (int i = 0; i < 5; i++)
  12.             {
  13.                
  14.             Console.Write("Введите пароль: ");
  15.                 while (true)
  16.                 {
  17.                     ConsoleKeyInfo CharKey = Console.ReadKey(true);
  18.                     if (CharKey.Key == ConsoleKey.Enter)
  19.                     {
  20.                         if (pass == Password)
  21.                         {
  22.                             Console.Clear();
  23.                             Console.SetCursorPosition(Console.WindowWidth / 2 - secret.Length / 2, Console.WindowHeight / 2 - 1);
  24.                             Console.Write(secret);
  25.                             Console.SetCursorPosition(Console.WindowWidth / 2 - secret.Length / 2, Console.WindowHeight / 2 + 1);
  26.                             return;
  27.                         }
  28.                         else
  29.                         {
  30.                             Console.WriteLine("\nПароль неверный! Осталось попыток: "+(5-i-1));
  31.  
  32.                         }
  33.                         break;
  34.                     }
  35.                     else if (CharKey.Key == ConsoleKey.Backspace)
  36.                     {
  37.                         Password = Password.Remove(Password.Length - 1);
  38.                         Console.Write("\b \b");
  39.                     }
  40.                     else
  41.                     {
  42.                         Password += CharKey.KeyChar;
  43.                         Console.Write("*");
  44.                     }
  45.                 }
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement