Exemplo n.º 1
0
 public int get_id(Baza_danych b)
 {
     this.id = 1 + b.size();
     return(this.id);
 }
Exemplo n.º 2
0
        public int przegladaj(Baza_danych b)
        {
            Console.Clear();
            Console.WriteLine("PRZEGLĄDAJ OFERTY");
            Console.WriteLine("-------------");
            for (int i = 1; i <= b.size(); i++)
            {
                Console.Write(++i + ". ");
                --i;
                Console.WriteLine("id [{0}], marka [{1}], model [{2}], rok [{3}], przebieg [{4}km], cena [{5}zl]", i, b.get_marka(i), b.get_model(i), b.get_rok(i), b.get_przebieg(i), b.get_cena(i));
            }
            Console.WriteLine("-------------");
            Console.WriteLine("Aby posortowac wzgledem ceny wcisnij 80");
            Console.WriteLine("Aby wrocic kliknij 0");
            Console.WriteLine("Aby wyszukac konkretne auto wcisnij 90");
            Console.WriteLine("Aby dodac ogloszenia kliknij 98");
            Console.WriteLine("Aby dodac ogloszenie do koszyka wcisnij numer ogloszenia");

            int klucz = Convert.ToInt32(Console.ReadLine());

            if (klucz == 98)
            {
                Ogloszenie ogl = new Ogloszenie(b);
                ogl.dodaj(b);
                Console.WriteLine("Twoje ogłoszenie dodano poprawnie");
                Console.ReadKey();
                klucz = 0;
            }
            if (klucz == 80)
            {
                b.sortuj_wzgledem_ceny();
                Console.WriteLine("-------------");
                Console.WriteLine("Aby wrocic kliknij 0");
                Console.WriteLine("Aby dodac ogloszenia kliknij 98");
                Console.WriteLine("Aby dodac ogloszenie do koszyka wcisnij id ogloszenia");
                klucz = Convert.ToInt32(Console.ReadLine());
            }
            if (klucz == 90)
            {
                Console.Write("Podaj marke: ");
                string mar = Console.ReadLine();
                b.szukaj(mar);
                Console.WriteLine("-------------");
                Console.WriteLine("Aby wrocic kliknij 0");
                Console.WriteLine("Aby dodac ogloszenie do koszyka wcisnij id ogloszenia");
                klucz = Convert.ToInt32(Console.ReadLine());
            }
            while (klucz != 0)
            {
                if (user.islogged)
                {
                    int id1 = klucz;
                    kosz.id_pr.Add(id1);
                    string mark  = b.get_marka(id1);
                    string mode  = b.get_model(id1);
                    int    ro    = b.get_rok(id1);
                    int    przeb = b.get_przebieg(id1);
                    int    cen   = b.get_cena(id1);
                    b.dodaj_do_koszyka(id1, mark, mode, ro, przeb, cen);
                    Console.WriteLine("Dodano przedmiot poprawnie, aby wyjsc wcisnij 0");
                    Console.WriteLine("Aby dodac kolejne przedmioty podaj ich numer");
                    klucz = Convert.ToInt32(Console.ReadLine());
                }
                else
                {
                    Console.WriteLine("Musisz byc zalogowany");
                    Console.ReadKey();
                    klucz = 0;
                }
            }
            return(klucz);
        }