Advertisement
Kocyk

kotipiespiesikot

Oct 11th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. namespace kot
  4. {
  5.     string imie;
  6.     int humor;
  7.     int glod;
  8.     int zmecznie;
  9.     void baw_sie(float czas);
  10.     void odpoczywaj(float czas);
  11.     void jedz(float ilosc);
  12.     void pokastaty(int humor,int glod,int zmeczenie,string imie);
  13. }
  14. namespace pies
  15. {
  16.     string imie;
  17.     int humor;
  18.     int glod;
  19.     int zmecznie;
  20.     void baw_sie(float czas);
  21.     void odpoczywaj(float czas);
  22.     void jedz(float ilosc);
  23.     void pokastaty(int humor,int glod,int zmeczenie,string imie);
  24. }
  25. void kot::baw_sie(float czas)
  26. {
  27.     if(czas>0)
  28.     {
  29.         glod+= 0.5*czas;
  30.         zmecznie+=0.5*czas;
  31.         humor+=czas;
  32.         pies::humor-=1;
  33.     }
  34. }
  35. void kot::odpoczywaj(float czas)
  36. {
  37.     zmecznie-=czas;
  38.     glod+=0.5*czas;
  39. }
  40. void kot::jedz(float ilosc)
  41. {
  42.      glod-=ilosc;
  43. }
  44. void pies::baw_sie(float czas)
  45. {
  46.     if(czas>0)
  47.     {
  48.         glod+= 0.5*czas;
  49.         zmecznie+=0.5*czas;
  50.         humor+=czas;
  51.         kot::humor-=1;
  52.     }
  53. }
  54. void pies::odpoczywaj(float czas)
  55. {
  56.     zmecznie-=czas;
  57.     glod+=0.5*czas;
  58. }
  59. void pies::jedz(float ilosc)
  60. {
  61.      glod-=ilosc;
  62. }
  63. void pies::pokastaty(int humor, int glod, int zmeczenie, string imie)
  64.     {
  65.         cout << "Imie : " << imie << endl << "humor : " << humor << endl << "gold : " << glod << endl << "zmeczenie : " << zmeczenie << endl;
  66.     }
  67. void kot::pokastaty(int humor, int glod, int zmeczenie, string imie)
  68.     {
  69.         cout << "Imie : " << imie << endl << "humor : " << humor << endl << "gold : " << glod << endl << "zmeczenie : " << zmeczenie << endl;
  70.     }
  71. int main()
  72. {
  73.     pies::imie="Brucyfal";
  74.     kot::imie="Kapsztad";
  75.           int wybor, czas;
  76.             do{
  77.                    cout << "Co chcesz zrobic?" << endl;
  78.                    cout << "1. Bawic sie z psem" << endl;
  79.                    cout << "2. Dac psu odpoczac" << endl;
  80.                    cout << "3. Nakarmic psa" << endl;
  81.                    cout << "4. Pokazac statystyki psa" << endl;
  82.                    cout << "5. Bawic sie z kotem" << endl;
  83.                    cout << "6. Dac kotu odpoczac" << endl;
  84.                    cout << "7. Nakarmic kota" << endl;
  85.                    cout << "8. Pokazac statystyki kota" << endl;
  86.                    cout << "9. Juz nic nie chcesz" << endl;
  87.  
  88.                    cin >> wybor;
  89.                    switch(wybor)
  90.                         {
  91.                            case 1:
  92.                                 cout << "Jak dlugo chcesz sie bawic" << endl;
  93.                                 cin >> czas;
  94.                                 pies::baw_sie(czas);
  95.                            break;
  96.                            case 2:
  97.                                 cout << "Jak dlugo chcesz dac mu odpaczac" << endl;
  98.                                 cin >> czas;
  99.                                 pies::odpoczywaj(czas);
  100.                            break;
  101.                            case 3:
  102.                                 cout << "Jak duzo chcesz mu dac jedzenia" << endl;
  103.                                 cin >> czas;
  104.                                 pies::jedz(czas);
  105.                                 break;
  106.                            case 4:
  107.                                 pies::pokastaty(pies::humor,pies::glod, pies::zmecznie, pies::imie);
  108.                            break;
  109.                            case 5:
  110.                                 cout << "Jak dlugo chcesz sie bawic" << endl;
  111.                                 cin >> czas;
  112.                                 kot::baw_sie(czas);
  113.                            break;
  114.                            case 6:
  115.                                 cout << "Jak dlugo chcesz dac mu odpaczac" << endl;
  116.                                 cin >> czas;
  117.                                 kot::odpoczywaj(czas);
  118.                            break;
  119.                            case 7:
  120.                                 cout << "Jak duzo chcesz mu dac jedzenia" << endl;
  121.                                 cin >> czas;
  122.                                 kot::jedz(czas);
  123.                            break;
  124.                            case 8:
  125.                                 kot::pokastaty(kot::humor,kot::glod, kot::zmecznie, kot::imie);
  126.                            break;
  127.                            case 9: cout << " Zakonczyles program";  break;
  128.                            default : cout <<" Zly numer, sprobuj jeszcze raz" << endl;
  129.                        }
  130.  
  131.                    }
  132.                    while (wybor != 9);
  133.             return 0;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement