static void Main(string[] args)
        {
            IBase baza = new Baza(new RandomFiller(30));
            baza.Add(new Borrow(baza.GetBookById(3), baza.GetReaderById(3)));
            baza.Add(new Borrow(baza.GetBookById(3), baza.GetReaderById(3)));
            /*var dist = baza.GetDistinctBorrows();
            foreach (var bor in dist) Console.WriteLine("DISTINCT: " + bor);*/
            Inputter inp = new Inputter();
            baza.AnulujWypozyczenieNr(0);
            //baza.Write();
            Console.WriteLine();
            Console.WriteLine("print, stat, +reader, -reader, +book, -book, +borrow, -borrow, stop,");
            Console.WriteLine("bookswithtitle, bookswithyear, readerswithborrows, latestbook, distinctborrows");
            string wybor;
            while (true) {
                Console.WriteLine("\nWybierz komende:");
                wybor = Console.ReadLine();
                if (wybor == "STOP" || wybor == "stop") {
                    Console.WriteLine("Stop.");
                    break;
                }
                switch (wybor) {
                    case "print":
                        baza.Write();
                        break;

                    case "stat":
                        Console.WriteLine("Liczba ksiazek: " + baza.LiczbaKsiazek);
                        Console.WriteLine("Liczba czytalnikow: " + baza.LiczbaCzytelnikow);
                        Console.WriteLine("Liczba wypozyczen: " + baza.LiczbaWypozyczen);
                        break;

                    case "+reader":
                        Console.Write("Imie: ");
                        string imie = Console.ReadLine();
                        Console.Write("Nazwisko: ");
                        string nazwisko = Console.ReadLine();
                        int id = -1;
                        if (!inp.GetInt("ID (nonpositive to get receive automatically): ", out id)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        if (id<0)
                            baza.Add(new Reader(imie, nazwisko));
                        else {
                            Console.WriteLine(id);
                            try {
                                Reader nowy = new Reader(imie, nazwisko, id);
                                baza.Add(nowy);
                            } catch (Exception e) {
                                Console.WriteLine(e.Message);
                                break;
                            }

                        }

                        break;

                    case "-reader":
                        int idr;
                        if (!inp.GetInt("ID (nonpositive will cancel): ", out idr)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        if (idr < 0)
                            break;
                        else {
                            try {
                                baza.RemoveReaderWithId(idr);
                            } catch (Exception e) {
                                Console.WriteLine(e.Message);
                                break;
                            }
                        }

                        break;

                    case "+book":
                        Console.Write("Tytul: ");
                        string tutul = Console.ReadLine();
                        int idb;
                        if (!inp.GetInt("ID: ", out idb) || idb < 0) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        try{
                            baza.Add(new Book(idb, tutul));
                        } catch (ArgumentException ae) {
                            Console.WriteLine(ae.Message + " Wcześniej.");
                        }

                        break;

                    case "-book":
                        int idb2;
                        if (!inp.GetInt("ID: ", out idb2)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }

                        baza.RemoveBookWithId(idb2);
                        break;

                    case "+borrow":
                        int ksID, czID;
                        if (!inp.GetInt("Book ID: ", out ksID)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }

                        if (!inp.GetInt("Reader ID: ", out czID)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        try {
                            baza.Add(new Borrow(baza.GetBookById(ksID), baza.GetReaderById(czID)));
                        } catch (KeyNotFoundException ke) {
                            Console.WriteLine(ke.Message);
                        }
                        break;

                    case "-borrow": {
                            int wypID;
                            if (!inp.GetInt("Number of Borrow Receipt on the list: ", out wypID)) {
                                Console.WriteLine("Invalid number");
                                break;
                            }
                            baza.AnulujWypozyczenieNr(wypID);
                        }
                        break;

                    case "bookswithtitle":{
                        Console.Write("Title of the book: ");
                        string title = Console.ReadLine();
                        var ksiazki = baza.GetBooksWithSpecifiedTitle(title);
                        foreach (var k in ksiazki)
                            Console.WriteLine(k);
                        }
                        break;

                    case "bookswithyear": {
                        int minYear, maxYear;
                        if (!inp.GetInt("Minimum issue year: ", out minYear)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }

                        if (!inp.GetInt("Maximum issue year: ", out maxYear)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        var ksiazki = baza.GetBooksWithSpecifiedIssueYear(minYear, maxYear);
                        foreach (var k in ksiazki)
                            Console.WriteLine(k);
                        }
                        break;

                    case "readerswithborrows": {
                        var readers = baza.GetReadersWithBorrows();
                            foreach (var k in readers)
                                Console.WriteLine(k + " (" + k.Borrows.Count + " borrows)");
                        }
                        break;

                    case "latestbook":
                        Console.WriteLine(baza.GetLatestBook());
                        break;

                    case "distinctborrows": {
                        var borrows = baza.GetDistinctBorrows();
                            foreach (var k in borrows)
                                Console.WriteLine(k.Ksiazka + " -> " + k.Czytelnik );
                        }
                        break;
                }
            }
        }
        static void Main(string[] args)
        {
            IBase baza = new Baza(new MassFiller(15));
            //baza.Add(new Czytelnik("a", "k", 333));
            Inputter inp = new Inputter();
            baza.AnulujWypozyczenieNr(0);
            //baza.Write();
            Console.WriteLine();
            Console.WriteLine("print, stat, +reader, -reader, +book, -book, +rent, -rent");
            string wybor;
            while (true) {
                Console.WriteLine("\nWybierz komende:");
                wybor = Console.ReadLine();
                if (wybor == "STOP" || wybor == "stop") {
                    Console.WriteLine("Stop.");
                    break;
                }
                switch (wybor) {
                    case "print":
                        baza.Write();
                        break;

                    case "stat":
                        Console.WriteLine("Liczba ksiazek: " + baza.LiczbaKsiazek);
                        Console.WriteLine("Liczba czytalnikow: " + baza.LiczbaCzytelnikow);
                        Console.WriteLine("Liczba wypozyczen: " + baza.LiczbaWypozyczen);
                        break;

                    case "+reader":
                        Console.Write("Imie: ");
                        string imie = Console.ReadLine();
                        Console.Write("Nazwisko: ");
                        string nazwisko = Console.ReadLine();
                        int id = -1;
                        if (!inp.GetInt("ID (nonpositive to get receive automatically): ", out id)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        if (id<0)
                            baza.Add(new Czytelnik(imie, nazwisko));
                        else {
                            Console.WriteLine(id);
                            try {
                                Czytelnik nowy = new Czytelnik(imie, nazwisko, id);
                                baza.Add(nowy);
                            } catch (Exception e) {
                                Console.WriteLine(e.Message);
                                break;
                            }

                        }

                        break;

                    case "-reader":
                        int idr;
                        if (!inp.GetInt("ID (nonpositive will cancel): ", out idr)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        if (idr < 0)
                            break;
                        else {
                            try {
                                baza.RemoveReaderWithId(idr);
                            } catch (Exception e) {
                                Console.WriteLine(e.Message);
                                break;
                            }
                        }

                        break;

                    case "+book":
                        Console.Write("Tytul: ");
                        string tutul = Console.ReadLine();
                        int idb;
                        if (!inp.GetInt("ID: ", out idb) || idb < 0) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        try{
                            baza.Add(new Ksiazka(idb, tutul));
                        } catch (ArgumentException ae) {
                            Console.WriteLine(ae.Message + " Wcześniej.");
                        }

                        break;

                    case "-book":
                        int idb2;
                        if (!inp.GetInt("ID: ", out idb2)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }

                        baza.RemoveBookWithId(idb2);
                        break;

                    case "+rent":
                        int ksID, czID;
                        if (!inp.GetInt("Book ID: ", out ksID)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }

                        if (!inp.GetInt("Reader ID: ", out czID)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        try {
                            baza.Add(new Wypozyczenie(baza.GetBookById(ksID), baza.GetReaderById(czID)));
                        } catch (KeyNotFoundException ke) {
                            Console.WriteLine(ke.Message);
                        }
                        break;

                    case "-rent":
                        int wypID;
                        if (!inp.GetInt("Number of Rent Receipt on the list: ", out wypID)) {
                            Console.WriteLine("Invalid number");
                            break;
                        }
                        baza.AnulujWypozyczenieNr(wypID);
                        break;
                }
            }
        }
        public void RemoveBookWithIdTest()
        {
            Baza b = new Baza(new RandomFiller(15));
            var ks = new Ksiazka(43, "K");
            b.Add(ks);

            Ksiazka wyluskana = b.GetBookById(43);
            Assert.AreEqual(ks, wyluskana);

            b.RemoveBookWithId(43);
            Ksiazka wyluskana2 = b.GetBookById(43);
        }