Advertisement
rukvir

HW 2_8

Feb 12th, 2025
190
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 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.  
  16.             Console.WriteLine("Введите пароль");
  17.             for (int i = 1; i <= numberTries; i++)
  18.             {
  19.                 userPassword = Console.ReadLine();
  20.                 if (userPassword == systemPassword)
  21.                 {
  22.                     Console.WriteLine(secretMessage);
  23.                     Console.WriteLine($"Пароль верный, программа закроется через {exitDelayTime}  секунд...");
  24.                     Thread.Sleep(exitDelayTime);
  25.                     return;
  26.                 }
  27.                 else if (i == numberTries)
  28.                 {
  29.                     return;
  30.                 }
  31.                 else
  32.                     Console.WriteLine($"У вас осталось {numberTries - i} попыток.");
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement