/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <vector>

using namespace std;

class Zwierze
{
  string imie;
  double waga;
  int wiek;
  
  public:
  Zwierze(string imie, double waga, int wiek)
  {
      this->imie = imie;
      this->waga = waga;
      this->wiek = wiek;
  }
  
  void WyswietlDane()
  {
      cout << imie << ", " << to_string(waga) << "kg, " << to_string(wiek) << " lat" << endl;
  }
};


class Osoba
{
  string imie;
  string nazwisko;
  
  public:
  string pesel;
  vector<Zwierze> zwierzeta;
  
  public:
  Osoba(string pesel = "nieznany", string imie = "puste", string nazwisko = "puste")
  {
      this->imie = imie;
      this->nazwisko = nazwisko;
      this->pesel = pesel;
  }
  
  void WyswietlDane()
  {
      cout << "Imię: " << imie << endl;
      cout << "Nazwisko: " <<  nazwisko << endl;
      cout << "Pesel: " << pesel << endl;
      
      
      cout << "Zwierzęta: " << endl;
      for(int i = 0; i < zwierzeta.size(); i++)
      {
          zwierzeta[i].WyswietlDane();
      }
  }
};

class ObslugaOsob
{
    public:
    vector<Osoba> listaOsob;  
  
    void DodajOsobe()
    {
        string imie, nazwisko, pesel;
        cout << "Podaj imie: ";
        cin >> imie;
        cout << "\nPodaj nazwisko: ";
        cin >> nazwisko;
        cout << "\nPodaj pesel: ";
        cin >> pesel;
        
        Osoba o1(pesel, imie, nazwisko);
        
        
        int ileZwierzat;
        cout << "Podaj ile masz zwierząt: ";
        cin >> ileZwierzat;
        
        for(int i = 0; i < ileZwierzat; i++)
        {
            string imieZwierza;
            double wagaZwierza;
            int wiekZwierza;
            
            cout << "\nImie zwierzęcia: ";
            cin >> imieZwierza;
            cout << "\nWaga zwierzęcia: ";
            cin >> wagaZwierza;
            cout << "\nWiek zwierzęcia: ";
            cin >> wiekZwierza;
            
            Zwierze z1(imieZwierza, wagaZwierza, wiekZwierza);
            o1.zwierzeta.push_back(z1);
        }
        
        
        listaOsob.push_back(o1);
        
        system("clear");
    }
    
    void WyszukajOsobe()
    {
        string pesel;
        cout << "Podaj pesel osoby, której szukasz: ";
        cin >> pesel;
        
        for(int i=0; i < listaOsob.size(); i++)
         {
             if(listaOsob[i].pesel == pesel)
             {
                listaOsob[i].WyswietlDane();
             }
         }
    }
    
    void WyswietlWszystkieOsoby()
    {
         cout << "\nWyświetlam wszystkie dane\n";
         
         
         for(int i=0; i < listaOsob.size(); i++)
         {
             cout << "Osoba nr " << i+1 << " - " << endl;
             listaOsob[i].WyswietlDane();
         }
    }
    
    
    int WyswietlMenu()
    {
        int pozMenu;
        
        cout << "\n\nWitamy w aplikacji\n\n" << endl;
        cout << "1. Dodaj osobę" << endl;
        cout << "2. Przeglądaj osoby" << endl;
        cout << "3. Wyszukaj osobę" << endl;
        
        cout << "\nWybierz numer..." << endl;
        cin >> pozMenu;
        
        cout << endl << endl;
        
        return pozMenu;
    }
};


int main()
{
    /*
    int ileOsob;
    
    cout << "Ile nowych osob chcesz dodac?" << endl;
    cin >> ileOsob;
    
    Osoba osoby[ileOsob];
    
    for(int i=0; i < ileOsob; i++)
    {
        string imie, nazwisko, pesel;
        cout << "Podaj imie: ";
        cin >> imie;
        cout << "\nPodaj nazwisko: ";
        cin >> nazwisko;
        cout << "\nPodaj pesel: ";
        cin >> pesel;
        
        Osoba o1(pesel, imie, nazwisko);
        osoby[i] = o1;
    }
    
    
    for(int i=0; i < ileOsob; i++)
    {
        cout << "Osoba nr " << i+1 << " - " << endl;
        osoby[i].WyswietlDane();
    }
*/

    ObslugaOsob obsluga;

    
    startMenu:
    int pozMenu = obsluga.WyswietlMenu();
    
    switch(pozMenu)
    {
        case 1:
            obsluga.DodajOsobe();
            goto startMenu;
        case 2:
            obsluga.WyswietlWszystkieOsoby();
            goto startMenu;
        case 3:
            obsluga.WyszukajOsobe();
            goto startMenu;
        default:
            cout << "Podano zły numer..." << endl;
            goto startMenu;
    }




    return 0;
}

