Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- namespace kot
- {
- string imie;
- int humor;
- int glod;
- int zmecznie;
- void baw_sie(float czas);
- void odpoczywaj(float czas);
- void jedz(float ilosc);
- void pokastaty(int humor,int glod,int zmeczenie,string imie);
- }
- namespace pies
- {
- string imie;
- int humor;
- int glod;
- int zmecznie;
- void baw_sie(float czas);
- void odpoczywaj(float czas);
- void jedz(float ilosc);
- void pokastaty(int humor,int glod,int zmeczenie,string imie);
- }
- void kot::baw_sie(float czas)
- {
- if(czas>0)
- {
- glod+= 0.5*czas;
- zmecznie+=0.5*czas;
- humor+=czas;
- pies::humor-=1;
- }
- }
- void kot::odpoczywaj(float czas)
- {
- zmecznie-=czas;
- glod+=0.5*czas;
- }
- void kot::jedz(float ilosc)
- {
- glod-=ilosc;
- }
- void pies::baw_sie(float czas)
- {
- if(czas>0)
- {
- glod+= 0.5*czas;
- zmecznie+=0.5*czas;
- humor+=czas;
- kot::humor-=1;
- }
- }
- void pies::odpoczywaj(float czas)
- {
- zmecznie-=czas;
- glod+=0.5*czas;
- }
- void pies::jedz(float ilosc)
- {
- glod-=ilosc;
- }
- void pies::pokastaty(int humor, int glod, int zmeczenie, string imie)
- {
- cout << "Imie : " << imie << endl << "humor : " << humor << endl << "gold : " << glod << endl << "zmeczenie : " << zmeczenie << endl;
- }
- void kot::pokastaty(int humor, int glod, int zmeczenie, string imie)
- {
- cout << "Imie : " << imie << endl << "humor : " << humor << endl << "gold : " << glod << endl << "zmeczenie : " << zmeczenie << endl;
- }
- int main()
- {
- pies::imie="Brucyfal";
- kot::imie="Kapsztad";
- int wybor, czas;
- do{
- cout << "Co chcesz zrobic?" << endl;
- cout << "1. Bawic sie z psem" << endl;
- cout << "2. Dac psu odpoczac" << endl;
- cout << "3. Nakarmic psa" << endl;
- cout << "4. Pokazac statystyki psa" << endl;
- cout << "5. Bawic sie z kotem" << endl;
- cout << "6. Dac kotu odpoczac" << endl;
- cout << "7. Nakarmic kota" << endl;
- cout << "8. Pokazac statystyki kota" << endl;
- cout << "9. Juz nic nie chcesz" << endl;
- cin >> wybor;
- switch(wybor)
- {
- case 1:
- cout << "Jak dlugo chcesz sie bawic" << endl;
- cin >> czas;
- pies::baw_sie(czas);
- break;
- case 2:
- cout << "Jak dlugo chcesz dac mu odpaczac" << endl;
- cin >> czas;
- pies::odpoczywaj(czas);
- break;
- case 3:
- cout << "Jak duzo chcesz mu dac jedzenia" << endl;
- cin >> czas;
- pies::jedz(czas);
- break;
- case 4:
- pies::pokastaty(pies::humor,pies::glod, pies::zmecznie, pies::imie);
- break;
- case 5:
- cout << "Jak dlugo chcesz sie bawic" << endl;
- cin >> czas;
- kot::baw_sie(czas);
- break;
- case 6:
- cout << "Jak dlugo chcesz dac mu odpaczac" << endl;
- cin >> czas;
- kot::odpoczywaj(czas);
- break;
- case 7:
- cout << "Jak duzo chcesz mu dac jedzenia" << endl;
- cin >> czas;
- kot::jedz(czas);
- break;
- case 8:
- kot::pokastaty(kot::humor,kot::glod, kot::zmecznie, kot::imie);
- break;
- case 9: cout << " Zakonczyles program"; break;
- default : cout <<" Zly numer, sprobuj jeszcze raz" << endl;
- }
- }
- while (wybor != 9);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement