Untitled

 avatar
unknown
plain_text
a year ago
1.2 kB
9
Indexable
string[] menuItems = new string[]
{
    "Забронировать",
    "Выход"
};

int selectedIndex = 0;

while (true)
{
    Console.Clear();
    showMenu(menuItems);

    ConsoleKeyInfo keyInfo = Console.ReadKey();

    switch (keyInfo.Key)
    {
        case ConsoleKey.DownArrow:
            selectedIndex++;
            break;
        case ConsoleKey.UpArrow:
            selectedIndex--;
            break;
        default: break;
    }
    
}

string[,] seats = new string[10, 4];

int rows = seats.GetUpperBound(0) + 1;
int columns = seats.Length / rows;

for (int i = 0; i < rows; i++)
{
    for (int j = 0; j < columns; j++)
    {
        Console.Write("X \t");
    }
    Console.WriteLine();
}

void showMenu(string[] menuItems)
{
    Console.WriteLine("Меню:");
    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++;
        Console.WriteLine();
    }
}
Editor is loading...
Leave a Comment