kwest87

Untitled

Dec 27th, 2023
1,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.22 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp13
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             const int CommandSetName = 1;
  10.             const int CommandSetPassword = 2;
  11.             const int CommandChangePassword = 3;
  12.             const int CommandExit = 4;
  13.  
  14.             int userCommandInput;
  15.             string userName;
  16.             string userPassword = "";
  17.             string userOldPassword;
  18.             bool isWork = true;
  19.  
  20.             while (isWork)
  21.             {
  22.                 Console.WriteLine($"Введите команду : \n {CommandSetName}) Установить имя\n {CommandSetPassword}) Установить пароль" +
  23.                     $"\n {CommandChangePassword}) Изменить пароль\n {CommandExit}) Выход");
  24.                 userCommandInput = Convert.ToInt32(Console.ReadLine());
  25.  
  26.                 switch (userCommandInput)
  27.                 {
  28.                     case CommandSetName:
  29.                         Console.WriteLine("Установите имя");
  30.                         userName = Console.ReadLine();
  31.                         break;
  32.  
  33.                     case CommandSetPassword:
  34.                         Console.WriteLine("Установите пароль");
  35.                         userPassword = Console.ReadLine();
  36.                         break;
  37.  
  38.                     case CommandChangePassword:
  39.                         Console.WriteLine("Для замены пароля введите старый пароль : ");
  40.                         userOldPassword = Console.ReadLine();
  41.  
  42.                         if (userOldPassword == userPassword)
  43.                         {
  44.                             Console.WriteLine("Введите новый пароль : ");
  45.                             userPassword = Console.ReadLine();
  46.                         }
  47.                         else
  48.                         {
  49.                             Console.WriteLine("Пароль не подходит.");
  50.                         }
  51.                         break;
  52.  
  53.                     case CommandExit:
  54.                         isWork = false;
  55.                         break;
  56.                 }
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment