Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
1.9 kB
1
Indexable
Never
int selectedIndex = 0;

string[] menu = new string[]
{
    "Book",
    "Watch",
    "Exit"
};
while (true)
{
    Console.Clear();


    Console.WriteLine("Menu");

    for (int i = 0; i < menu.GetLength(0); i++)
    {
        if (selectedIndex == i)
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine($"{i + 1}. {menu[i]} <-_-_-_-");
        }
        else
        {
            Console.ResetColor();
            Console.WriteLine($"{i + 1}. {menu[i]}");
        }
    }

    ConsoleKeyInfo keyInfo = Console.ReadKey();

    switch (keyInfo.Key)
    {
        case ConsoleKey.UpArrow:
            if (selectedIndex >= 0)
            {
                selectedIndex--;
                if (selectedIndex < 0)
                {
                    selectedIndex = 0;
                    continue;
                }
            }
            break;


        case ConsoleKey.DownArrow:
            if (selectedIndex < menu.GetLength(0))
            {
                selectedIndex++;
                if (selectedIndex >= menu.GetLength(0)) 
                {
                    selectedIndex--;
                    continue;
                }
            }
            break;
    }
}
static void ShowSeats()
{
    string[,] aviaTickets = new string[6, 4]
    {
    { " [A1] ", " [A2] "," [A3] "," [A4] " },
    { " [B1] ", " [B2] "," [B3] "," [B4] " },
    { " [C1] ", " [C2] "," [C3] "," [C4] " },
    { " [D1] ", " [D2] "," [D3] "," [D4] " },
    { " [E1] ", " [E2] "," [E3] "," [E4] " },
    { " [F1] ", " [F2] "," [F3] "," [F4] " }
    };

    for (int i = 0; i < aviaTickets.GetLength(0); i++)
    {
        for (int j = 0; j < aviaTickets.GetLength(1); j++)
        {
            Console.Write(aviaTickets[i, j]);
        }
        Console.WriteLine();
    }
}
Leave a Comment