Airport service

mail@pastecode.io avatar
unknown
csharp
2 months ago
3.1 kB
3
Indexable
Never
internal class Program
{
    private static void Main(string[] args)
    {
        Console.OutputEncoding = System.Text.Encoding.UTF8;

        string[] menuItems = new string[] { "Забронировать билет", "Настройки", "Информация", "Выход" };
        int selectedIndex = 0;



        while (true)
        {
            Console.Clear();
            ShowMenu(menuItems);
            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:
                    switch (selectedIndex)
                    {

                        case 0:
                            ShowSeats();
                            break;
                        default:
                            break;

                    }
                    break;
                default:
                    break;
            }
        }




        void ShowMenu(string[] menuItems)
        {
            Console.WriteLine("\tAir 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++;
            }
        }

        void ShowSeats()
        {
            Console.Clear();
            string[,] seats = new string[10, 4];
            for (int i = 0; i < seats.GetLength(0); i++)
            {
                for (int j = 0; j < seats.GetLength(1); j++)
                {
                    Console.Write("[X] \t");

                }
                Console.WriteLine();
                Console.WriteLine();
            }

            int selectedSeatY = 0;
            int selectedSeatX = 0;

            ConsoleKeyInfo keyInfo = Console.ReadKey();

            switch (keyInfo.Key)
            {
                case ConsoleKey.RightArrow:
                    selectedSeatX++;
                    break;
                case ConsoleKey.LeftArrow:
                    selectedSeatX--;
                    break;
                case ConsoleKey.UpArrow:
                    selectedSeatY--;
                    break;
                case ConsoleKey.DownArrow:
                    selectedSeatY++;
                    break;
            }
            Console.ReadKey();
        }





    }
}
Leave a Comment