Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class pojazd{
- int liczba_kol;
- protected:
- string rejestracja;
- public:
- pojazd() {};
- ~pojazd() {};
- pojazd *poprz;
- pojazd *nast;
- char nazwa[20];
- pojazd(int l_kol, string rejestr) : liczba_kol(l_kol), rejestracja(rejestr) {}
- void wyswietl()
- {
- cout<<"Liczba kol: "<<liczba_kol<<endl;
- cout<<"Rejestracja: "<<rejestracja<<endl;
- }
- void Modyfikuj_pojazd()
- {
- cout<<"Podaj nazwe obiektu:"<<endl;
- cin>>nazwa;
- cout<<"Jaka liczbe kol ma posiadac pojazd?"<<endl;
- cin>>liczba_kol;
- cout<<"Jaka rejestracje ma posiadac pojazd"<<endl;
- cin>>rejestracja;
- }
- void zapis_pojazd(FILE *pFile)
- {
- fprintf(pFile,"\n%s\n%d\n%s", nazwa, liczba_kol, rejestracja.c_str());
- }
- void czytaj_pojazd(FILE *pFile)
- {
- fscanf(pFile,"\n%s\n%d\n%s", nazwa, liczba_kol, rejestracja.c_str());
- }
- };
- //B - na grafie projektu
- class jednoslady : public pojazd{
- int liczba_swiatel;
- protected:
- string kolor;
- public:
- jednoslady() {};
- ~jednoslady() {};
- jednoslady(int l_kol1, string rejestr1, int l_swiatel, string kol) : pojazd(l_kol1, rejestr1), liczba_swiatel(l_swiatel), kolor(kol) {}
- void wyswietl1()
- {
- wyswietl();
- cout<<"Liczba swiatel: "<<liczba_swiatel<<endl;
- cout<<"Kolor: "<<kolor<<endl;
- }
- void Modyfikuj_jednoslady()
- {
- Modyfikuj_pojazd();
- cout<<"Jaka liczbe swiatel ma miec pojazd"<<endl;
- cin>>liczba_swiatel;
- cout<<"Jaki kolor ma miec pojazd"<<endl;
- cin>>kolor;
- }
- void zapis_jednoslady(FILE *pFile)
- {
- zapis_pojazd(pFile);
- fprintf(pFile,"\n%d\n%s", liczba_swiatel, kolor.c_str());
- }
- void czytaj_jednoslad(FILE *pFile)
- {
- czytaj_pojazd(pFile);
- fscanf(pFile,"\n%d\n%s", liczba_swiatel, kolor.c_str());
- }
- };
- template <class pnt>
- pnt* Zapisz_plik(pnt *tmp)
- {
- char naswa[20];
- cout<<"Podaj nazwe pliku (z dopiskiem .txt)"<<endl;
- cin>>naswa;
- FILE *pFile;
- pFile=fopen(naswa, "w+");
- if(current==D_first)
- {
- if(D_first->nast!=NULL)
- {
- D_first=(rowery*)D_first->nast;
- while(D_first)
- {
- // fprintf(pFile, "Rowery");
- D_first->zapis_rowery(pFile);
- D_first=(rowery*)D_first->nast;
- }
- }
- D_first=(rowery*)tmp;}
- else if(current==E_first)
- {
- tmp=(motory*)E_first;
- E_first->zapis_motory(pFile);
- if(E_first->nast!=NULL)
- {
- E_first=(motory*)E_first->nast;
- while(E_first)
- {
- // fprintf(pFile, "Motory");
- E_first->zapis_motory(pFile);
- E_first=(motory*)E_first->nast;
- }
- }
- E_first=(motory*)tmp;}
- else if(current==K_first)
- {
- tmp=(lotniskowce*)K_first;
- K_first->zapis_lotniskowce(pFile);
- if(K_first->nast!=NULL)
- {
- K_first=(lotniskowce*)K_first->nast;
- while(K_first)
- {
- // fprintf(pFile, "Lotniskowce");
- K_first->zapis_lotniskowce(pFile);
- K_first=(lotniskowce*)K_first->nast;
- }
- }
- K_first=(lotniskowce*)tmp;}
- else if(current==J_first)
- {
- tmp=(kajaki*)J_first;
- J_first->zapis_kajaki(pFile);
- if(J_first->nast!=NULL)
- {
- J_first=(kajaki*)J_first->nast;
- while(J_first)
- {
- // fprintf(pFile, "Kajaki");
- J_first->zapis_kajaki(pFile);
- J_first=(kajaki*)J_first->nast;
- }
- }
- J_first=(kajaki*)tmp;}
- else if(current==L_first)
- {
- tmp=(kabriolety*)L_first;
- L_first->zapis_kabriolety(pFile);
- if(L_first->nast!=NULL)
- {
- L_first=(kabriolety*)L_first->nast;
- while(L_first)
- {
- //fprintf(pFile, "Kabriolety");
- L_first->zapis_kabriolety(pFile);
- L_first=(kabriolety*)L_first->nast;
- }
- }
- L_first=(kabriolety*)tmp;}
- else if(current==M_first)
- {
- tmp=(terenowe*)M_first;
- M_first->zapis_terenowe(pFile);
- if(M_first->nast!=NULL)
- {
- M_first=(terenowe*)M_first->nast;
- while(M_first)
- {
- //fprintf(pFile, "Terenowe");
- M_first->zapis_terenowe(pFile);
- M_first=(terenowe*)L_first->nast;
- }
- }
- }
- fclose(pFile);
- cout<<"Zapisano"<<endl<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement