Advertisement
rukvir

HW 2_8_2

Feb 13th, 2025
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace HW_2025
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string userPassword = "";
  11.             string systemPassword = "123Rfv";
  12.             string secretMessage = "Бутерброд надо есть колбасой вниз.";
  13.             int numberTries = 3;
  14.             int exitDelayTime = 3000;
  15.             int timeToExit = 0;
  16.  
  17.             Console.WriteLine("Введите пароль");
  18.  
  19.             for (int i = 1; i <= numberTries; i++)
  20.             {
  21.                 userPassword = Console.ReadLine();
  22.  
  23.                 if (userPassword == systemPassword)
  24.                 {
  25.                     Console.WriteLine(secretMessage);
  26.                     Console.WriteLine($"Пароль верный, программа закроется через {exitDelayTime} милисекунд...");
  27.                     Thread.Sleep(exitDelayTime);
  28.                     break;
  29.                 }
  30.                 else
  31.                 {
  32.                     timeToExit = numberTries - i;
  33.                     Console.WriteLine($"У вас осталось {timeToExit} попыток.");
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement