Advertisement
CYRAX228

Untitled

Feb 22nd, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Курсы_черновик
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Random rand = new Random();
  14.             int userImput;
  15.             string userImputPassword;
  16.             string password = "";
  17.             bool passwordOn = false;
  18.             bool programmOn = true;
  19.             while (programmOn)
  20.             {
  21.                 while (passwordOn)
  22.                 {
  23.                     Console.WriteLine("Введите пароль:");
  24.                     userImputPassword = Console.ReadLine();
  25.                     if (userImputPassword == password)
  26.                     {
  27.                         Console.WriteLine("Верный пароль.\n");
  28.                         break;
  29.                     }
  30.                     else
  31.                     {
  32.                         Console.WriteLine("Неверный пароль!");
  33.                     }
  34.                 }
  35.                 Console.WriteLine("Выберите действие\nСоздать(убрать) пароль-1\nБросить игральный кубик-2\nИзменить цвет текста-3\nНарисовать прямоугольник-4\nЗакрыть программу-5");
  36.                 userImput = Convert.ToInt32(Console.ReadLine());
  37.                 switch (userImput)
  38.                 {
  39.                     case 1:
  40.                         if (!passwordOn)
  41.                         {
  42.                             Console.WriteLine("Придумайте пароль:");
  43.                             password = Console.ReadLine();
  44.                             passwordOn = true;
  45.                         }
  46.                         else
  47.                         {
  48.                             passwordOn = false;
  49.                             Console.WriteLine("Пароль убран");
  50.                             Console.ReadKey();
  51.                         }
  52.                         break;
  53.                     case 2:
  54.                         int number = rand.Next(1, 7);
  55.                         Console.WriteLine($"Выпавшее число - {number}");
  56.                         Console.ReadKey();
  57.                         break;
  58.                     case 3:
  59.                         Console.WriteLine("Какой цвет вы хотите выбрать?\nЖелтый-1\nКрасный-2\nБелый(стандартный)-3");
  60.                         userImput = Convert.ToInt32(Console.ReadLine());
  61.                         switch (userImput)
  62.                         {
  63.                             case 1:
  64.                                 Console.ForegroundColor = ConsoleColor.Yellow;
  65.                                 break;
  66.                             case 2:
  67.                                 Console.ForegroundColor = ConsoleColor.Red;
  68.                                 break;
  69.                             case 3:
  70.                                 Console.ForegroundColor = ConsoleColor.Gray;
  71.                                 break;
  72.                         }
  73.                         break;
  74.                     case 4:
  75.                         Console.Write("Введите высоту прямоугольника:");
  76.                         int squareHeight = Convert.ToInt32(Console.ReadLine());
  77.                         Console.Write("Введите ширину прямоугольника:");
  78.                         int squareWidth = Convert.ToInt32(Console.ReadLine());
  79.                         Console.Write("Из каких символов нарисовать пямоугольник:");
  80.                         char squareSymbol = Convert.ToChar(Console.ReadLine());
  81.                         Console.WriteLine();
  82.                         for (int i = 0; i < squareHeight; i++)
  83.                         {
  84.                             for (int l = 0; l < squareWidth; l++)
  85.                             {
  86.                                 Console.Write(squareSymbol);
  87.                             }
  88.                             Console.WriteLine();
  89.                         }
  90.                         Console.ReadKey();
  91.                         break;
  92.                     case 5:
  93.                         programmOn = false;
  94.                         break;
  95.                     default:
  96.                         Console.WriteLine("Неправильный ввод!");
  97.                         Console.ReadKey();
  98.                         break;
  99.                 }
  100.                 Console.Clear();
  101.             }
  102.         }
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement