/*
Veidotajs: Andrejs Šorecs
Grupa: 110
Praktiskais darbs 6.3
Izmantotais Compiler: https://www.programiz.com/csharp-programming/online-compiler/
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
 
public class HelloWorld
{
 
    public static void Main()
    {
        List<string> rezervet = new List<string> { };
         int [][] vietas = new int[9][];
        vietas[8] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        vietas[7] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        vietas[6] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        vietas[5] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        vietas[4] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        vietas[3] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        vietas[2] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        vietas[1] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        vietas[0] = new int [] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        bool iziet = true;
        while (iziet)
        {
            Console.WriteLine();
            Console.WriteLine("1 paradit zali");
            Console.WriteLine("2 Rezervet vietu");
            Console.WriteLine("3 paradit rezervaciju sarakstu");
            Console.WriteLine("4 iziet");
            int ui = Convert.ToInt32(Console.ReadLine());
            switch (ui)
            {
            case 1:Paraditzali(vietas,rezervet);
            break;
            case 2:Rezervetvietu(vietas,rezervet);
            break;
            case 3:rezsar(vietas,rezervet);
            break;
            case 4:iziet = false;
            break;
            }
        }
 
    }
    public static void Paraditzali(int [][] vietas,List<string> rezervet)
    {
        Console.WriteLine("Zales vietas o=brivas vietas un x=aiznemtas vietas");
 
        for(int i =0;i<vietas.Length;i++)
        {
            Console.Write($"rinda{i+1}\t");
            for(int j =0;j<vietas[i].Length;j++)
            {
                Console.Write(vietas[i][j] == 0 ? "o " : "x ");
            }
            Console.WriteLine();
        }
    }
    public static void Rezervetvietu(int [][] vietas,List<string> rezervet)
    {
    Console.Write("Ievadiet vietas kolonu: ");
    int kl= Convert.ToInt32(Console.ReadLine());
    Console.Write("Ievadiet vietas rindu: ");
    int rn=Convert.ToInt32(Console.ReadLine());
    if (rn<1 || rn>9 || kl<1 || kl>16)
    {
        Console.WriteLine("Nepareiza ievade!");
        return;
    }
    if (vietas[rn-1][kl-1] == 1)
    {
        Console.WriteLine("Si vieta jau ir aiznemta!");
       return;
    }
        rezervet.Add($"Kolona ir {kl} Rinda ir {rn}");
        vietas[rn-1][kl-1] = 1;
        
        
    }   
    public static void rezsar(int [][] vietas,List<string> rezervet)
    {
        for(int i=0;i<rezervet.Count;i++)
        {
            Console.WriteLine(rezervet[i]);
        }
    }
}
