/*
    Veidotaja: Rolands Zviedris
    Grupa: 110
    Praktiskais darbs 6.3
    Izmantotais compiler: https://www.onlinegdb.com/online_csharp_compiler
*/
using System;
using System.Collections.Generic;
class HelloWorld {
    static void Main() 
    {
        int[][] vietas = new int[][]
        {
        new int[] { 0, 0, 0, 0, 0 },
        new int[] { 0, 0, 0, 0, 0, 0, 0 },
        new int[] { 0, 0, 0, 0 }       
        };
        List<string> r = new List<string>();
        bool iziet = false;
        while(iziet== false)
        {
            Console.WriteLine("1 – Parādīt zāli \n2 – Rezervēt vietu \n3 – Parādīt rezervāciju sarakstu \n4 – Iziet");
            switch(Int32.Parse(Console.ReadLine()))
            {
                case 1:
                    ParādītZāli(vietas);
                break;
                case 2:
                    RezervētVietu(vietas, r);
                break;
                case 3:
                    for(int l = 0; l<=r.Count-1; l++)
                    {
                        Console.WriteLine(r[l]);
                    }
                break;
                case 4:
                    iziet = true;
                    Console.WriteLine("Paldies ka apmeklejat musu saiti!");
                break;
                default:
                    Console.WriteLine("nav tadas opcijas!");
                break;
            }
        }
    }
    static void ParādītZāli(int[][] vietas)
    {
        for(int a = 0; a < vietas.Length; a++)
        {
            for(int b = 0; b < vietas[a].Length; b++)
            {
                if(vietas[a][b]== 0)
                {
                    Console.Write("O ");
                }
                else
                {
                    Console.Write("X ");
                }
            }
            Console.WriteLine();
        }
    }
    static bool RezervētVietu(int[][] vietas, List<string> r)
    {
        Console.Write("Izvelies sedvietas rindu ");
        int x = Int32.Parse(Console.ReadLine())-1;
        Console.Write("Izvelies sedvietu ");
        int y = Int32.Parse(Console.ReadLine())-1;
        if(x<= vietas.Length && y <= vietas[x].Length)
        {
            if(vietas[x][y] == 0)
            {
                r.Add($"Rinda {x+1} vieta {y+1}");
                vietas[x][y] = 1;
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            Console.WriteLine("Sedvieta neeksiste!");
            return false;
        }
    }
    static void ApstrādātIzvēl()
    {
        
    }
}