Spermix

HW11

Jul 16th, 2025 (edited)
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.30 KB | Source Code | 0 0
  1. using System;
  2.  
  3. namespace HomeWork
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             const string CommandGame = "Game";
  10.             const string CommandSaves = "Saves";
  11.             const string CommandSettings = "Settings";
  12.             const string CommandExit = "Exit";
  13.             const string CommandBack = "Back";
  14.             const string CommandClearConsole = "Clear Console";
  15.  
  16.             string playerInput;
  17.  
  18.             bool gameIsWorked = true;
  19.  
  20.             while (gameIsWorked)
  21.             {
  22.                 Console.Clear();
  23.                 Console.WriteLine("Доро пожаловать в меню игры");
  24.                 Console.WriteLine();
  25.                 Console.WriteLine("[Введите название пункта, чтобы перейти по пункту меню]");
  26.                 Console.WriteLine();
  27.                 Console.WriteLine();
  28.  
  29.                 Console.WriteLine($"1. [{CommandGame}]");
  30.                 Console.WriteLine($"2. [{CommandSaves}]");
  31.                 Console.WriteLine($"3. [{CommandSettings}]");
  32.                 Console.WriteLine($"4. [{CommandExit}]");
  33.                 Console.WriteLine($"5. [{CommandClearConsole}]");
  34.                 Console.WriteLine();
  35.                 Console.WriteLine();
  36.                 Console.Write("Ввод команды : ");
  37.  
  38.                 playerInput = Console.ReadLine();
  39.  
  40.                 Console.Clear();
  41.  
  42.                 switch (playerInput)
  43.                 {
  44.                     case CommandGame:
  45.                         const string CommandRollDice = "1";
  46.                         const string CommandExitGame = "2";
  47.  
  48.                         int minimumNumberOnCube = 1;
  49.                         int maximumNumberOnCube = 6;
  50.  
  51.                         Console.WriteLine($"У вас есть кубик с минимальным числом : {minimumNumberOnCube} и максимальным : {maximumNumberOnCube}");
  52.                         Console.WriteLine();
  53.                         Console.WriteLine();
  54.                         Console.WriteLine("[Введите номер пункта, чтобы перейти по пункту меню]");
  55.                         Console.WriteLine($"1. [Кинуть кубик]");
  56.                         Console.WriteLine($"2. [Выйти из игры]");
  57.                         Console.WriteLine();
  58.  
  59.                         Console.Write("Ввод команды : ");
  60.  
  61.                         playerInput = Console.ReadLine();
  62.  
  63.                         switch (playerInput)
  64.                         {
  65.                             case CommandRollDice:
  66.                                 Random random = new Random();
  67.  
  68.                                 int randomNumber = random.Next(minimumNumberOnCube, maximumNumberOnCube);
  69.  
  70.                                 Console.WriteLine($"Кубик выдал : {randomNumber}");
  71.                                 break;
  72.                             case CommandExitGame:
  73.                                 Environment.Exit(0);
  74.                                 break;
  75.                         }
  76.                         break;
  77.                     case CommandSaves:
  78.                         Console.WriteLine("Сохранения игры");
  79.                         Console.WriteLine();
  80.                         break;
  81.                     case CommandSettings:
  82.                         Console.WriteLine("Настройки игры");
  83.                         Console.WriteLine();
  84.                         break;
  85.                     case CommandExit:
  86.                         Environment.Exit(0);
  87.                         break;
  88.                     case CommandClearConsole:
  89.                         Console.Clear();
  90.                         break;
  91.                 }
  92.  
  93.                 Console.WriteLine();
  94.                 Console.WriteLine($"1. [{CommandBack}]");
  95.                 Console.WriteLine($"2. [{CommandExit}]");
  96.                 Console.WriteLine();
  97.                 Console.Write("Ввод команды : ");
  98.  
  99.                 playerInput = Console.ReadLine();
  100.  
  101.                 switch (playerInput)
  102.                 {
  103.                     case CommandExit:
  104.                         Environment.Exit(0);
  105.                         break;
  106.                 }
  107.             }
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment