Gntvv

mail@pastecode.io avatar
unknown
csharp
2 months ago
5.0 kB
1
Indexable
Never
GIntvvusing System.Transactions;  internal class Program {     private static void Main(string[] args)     {         string[] menuItems = new string[]             {                 "Забронировать билет",                 "Настройки",                 "Инфо",                 "Выход"             };         int selectedIndex = 0;          string[] setting = new string[]             {                 "1.Изменить цвет"              };           while (true)         {             Console.Clear();             ShowMenu(menuItems);             InputItem();         }          void InputItem()         {             ConsoleKeyInfo keyInfo = Console.ReadKey();             switch (keyInfo.Key)             {                 case ConsoleKey.DownArrow:                     if (selectedIndex < menuItems.Length - 1)                     {                         selectedIndex++;                     }                      break;                 case ConsoleKey.UpArrow:                     if (selectedIndex >= 1)                     {                         selectedIndex--;                     }                     break;                 case ConsoleKey.Enter:                     if (selectedIndex == 0)                     {                         ShowSeats();                      }                     if (selectedIndex == 1)                     {                            ShowMenu(setting);                         InputItem();                      }                     else if (selectedIndex == 2)                     {                         return;                      }                      break;                 default:                     break;             }         }          void ShowMenu(string[] menuItems)         {             Console.Clear();             Console.WriteLine("   Air Astana");             int a = 1;             foreach (string item in menuItems)             {                 if (a - 1 == selectedIndex)                 {                     Console.ForegroundColor = ConsoleColor.Blue;                  }                 else                 {                     Console.ResetColor();                 }                 Console.WriteLine(a + ". " + item);                 Console.ResetColor();                 a++;             }                      }          static void ShowSeats()         {             int selectedSeatX = 0;             int selectedSeatY = 0;              while (true)             {                 Console.Clear();                 string[,] seats = new string[10, 4]                 {                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                     { "     \t[X]","[X]","[X]","[X]", },                 };                   for (int i = 0; i < seats.GetLength(0); i++)                 {                     for (int j = 0; j < seats.GetLength(1); j++)                     {                          if (i == selectedSeatY && j == selectedSeatX)                         {                             Console.ForegroundColor = ConsoleColor.Blue;                         }                         else                         {                             Console.ResetColor();                         }                          Console.Write(seats[i, j] + " ");                     }                     Console.WriteLine();                     Console.WriteLine();                   }                   ConsoleKeyInfo keyInfo = Console.ReadKey();                  switch (keyInfo.Key)                 {                     case ConsoleKey.RightArrow:                         if (selectedSeatX < seats.GetLength(1) - 1)                         {                             selectedSeatX++;                         }                         break;                     case ConsoleKey.LeftArrow:                         if (selectedSeatX > 0)                         {                             selectedSeatX--;                         }                         break;                     case ConsoleKey.UpArrow:                         if (selectedSeatY > 0)                         {                             selectedSeatY--;                         }                         break;                     case ConsoleKey.DownArrow:                         if (selectedSeatY < seats.GetLength(0) - 1)                         {                             selectedSeatY++;                         }                         break;                  }             }            }      } }
Leave a Comment