Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class game {
  8. private:
  9.     int x;
  10. protected:
  11.     int number_of_players;
  12.  
  13. };
  14.  
  15. class board_game : public game {
  16. private:
  17.     int x;
  18. protected:
  19.     int number_of_pawns;
  20. };
  21.  
  22. class card_game : public game {
  23. private:
  24.     int x;
  25. protected:
  26.     int number_of_cards;
  27. };
  28.  
  29. class computer_game : public game {
  30. private:
  31.     int x;
  32. protected:
  33.     bool online;
  34. };
  35.  
  36. class cooperative : public board_game {
  37. private:
  38.     int id;
  39. protected:
  40.     bool traitor;
  41. public:
  42.     cooperative(int);
  43.  
  44.     ~cooperative();
  45.  
  46.     void show_details();
  47.  
  48.     int get_id();
  49. };
  50.  
  51. cooperative::cooperative(int id_number) {
  52.     bool traitor_mo;
  53.     int players;
  54.     int pawns;
  55.     cout << "Liczba graczy:" << endl;
  56.     cin >> players;
  57.     cout << "Liczba pionków:" << endl;
  58.     cin >> pawns;
  59.     cout << "Czy obecny jest zdrajca? (1 - tak, 0 - nie)" << endl;
  60.     cin >> traitor_mo;
  61.  
  62.     id = id_number;
  63.     number_of_players = players;
  64.     number_of_pawns = pawns;
  65.     traitor = traitor_mo;
  66. }
  67.  
  68. cooperative::~cooperative() {
  69.     cout << "Objekt usunięty" << endl;
  70. }
  71.  
  72. int cooperative::get_id() {
  73.     return id;
  74. }
  75.  
  76.  
  77. void cooperative::show_details() {
  78.  
  79.     cout << "Liczba graczy: " << number_of_players << "/n" << "Liczba pionków: " << number_of_pawns
  80.          << "/n";
  81.     if (traitor) {
  82.         cout << "Zdrajca: obecny" << endl;
  83.     } else {
  84.         cout << "Brak zdrajcy" << endl;
  85.     }
  86.  
  87. }
  88.  
  89. void mdo_e(list <cooperative> objs, int id_number) {
  90.     for (std::list<cooperative>::iterator it = objs.begin(); it != objs.end(); ++it) {
  91.         if(it->get_id() == id_number){
  92.             objs.remove(*it);
  93.         }
  94.     }
  95.     cooperative obj(id_number);
  96.     objs.push_back(obj);
  97. }
  98.  
  99. //void cooperative::DO(list <cooperative> e_objects) {
  100. //    int temp_id;
  101. //    cout << "Podaj id obiektu który chcesz usunąć" << endl;
  102. //    cin >> temp_id;
  103. //    for (std::list<cooperative>::iterator it = e_objects.begin(); it != e_objects.end(); ++it) {
  104. //        if ((*it).id == temp_id) {
  105. //            e_objects.remove(*it);
  106. //            break;
  107. //        }
  108. //    }
  109. //
  110. //}
  111.  
  112. //void cooperative::DIR(list <cooperative> e_objects) {
  113. //    cout << "Obiekty E:" << endl;
  114. //    for (std::list<cooperative>::iterator it = e_objects.begin(); it != e_objects.end(); ++it) {
  115. //        cout << "objekt" << it->id << endl;
  116. //    }
  117. //}
  118.  
  119. //cout << "Podaj id obiektu którego szczegóły chcesz zobaczyć" << endl;
  120. //cin >> temp_id;
  121. //for (std::list<cooperative>::iterator it = e_objects.begin(); it != e_objects.end(); ++it) {
  122. //if (it->id == temp_id) {
  123.  
  124. class individual : public board_game {
  125. private:
  126.     int id;
  127. protected:
  128.     int enemy;
  129. public:
  130.     individual(int);
  131.  
  132.     ~individual();
  133.  
  134.     void show_details();
  135.  
  136.     int get_id();
  137. };
  138.  
  139. individual::individual(int id_number) {
  140.     int enemy_mo;
  141.     int players;
  142.     int pawns;
  143.     cout << "Liczba graczy:" << endl;
  144.     cin >> players;
  145.     cout << "Liczba pionków:" << endl;
  146.     cin >> pawns;
  147.     cout << "Liczba przeciwników: " << endl;
  148.     cin >> enemy_mo;
  149.  
  150.     id = id_number;
  151.     number_of_players = players;
  152.     number_of_pawns = pawns;
  153.     enemy = enemy_mo;
  154. }
  155.  
  156. individual::~individual() {
  157.     cout << "Objekt usunięty" << endl;
  158. }
  159.  
  160. int individual::get_id() {
  161.     return id;
  162. }
  163.  
  164. void individual::show_details() {
  165.  
  166.     cout << "Liczba graczy: " << number_of_players << "/n" << "Liczba pionków: " << number_of_pawns
  167.          << "/n" << "Liczba przeciwników: " << enemy << "/n";
  168. }
  169.  
  170. void mdo_f(list <individual> objs, int id_number) {
  171.     for (std::list<individual>::iterator it = objs.begin(); it != objs.end(); ++it) {
  172.         if(it->get_id() == id_number){
  173.             objs.remove(*it);
  174.         }
  175.     }
  176.     individual obj(id_number);
  177.     objs.push_back(obj);
  178. }
  179.  
  180. class card : public card_game {
  181. private:
  182.     int id;
  183. protected:
  184.     int hand;
  185. public:
  186.     card(int);
  187.  
  188.     ~card();
  189.  
  190.     void show_details();
  191.  
  192.     int get_id();
  193. };
  194.  
  195. card::card(int id_number) {
  196.     int cards_mo;
  197.     int players;
  198.     int hand_mo;
  199.     cout << "Liczba graczy:" << endl;
  200.     cin >> players;
  201.     cout << "Liczba kart:" << endl;
  202.     cin >> cards_mo;
  203.     cout << "Liczba kart na ręce: " << endl;
  204.     cin >> hand_mo;
  205.  
  206.     id = id_number;
  207.     number_of_players = players;
  208.     number_of_cards = cards_mo;
  209.     hand = hand_mo;
  210. }
  211.  
  212. card::~card() {
  213.     cout << "Objekt usunięty" << endl;
  214. }
  215.  
  216. int card::get_id() {
  217.     return id;
  218. }
  219.  
  220. void card::show_details() {
  221.  
  222.     cout << "Liczba graczy: " << number_of_players << "/n" << "Liczba kart: " << number_of_cards
  223.          << "/n" << "Liczba kart na ręce: " << hand << "/n";
  224. }
  225.  
  226. void mdo_g(list <card> objs, int id_number) {
  227.     for (std::list<card>::iterator it = objs.begin(); it != objs.end(); ++it) {
  228.         if(it->get_id() == id_number){
  229.             objs.remove(*it);
  230.         }
  231.     }
  232.     card obj(id_number);
  233.     objs.push_back(obj);
  234. }
  235.  
  236. class single : public computer_game {
  237. private:
  238.     int id;
  239. protected:
  240.     int enemy;
  241. public:
  242.     single(int);
  243.  
  244.     ~single();
  245.  
  246.     void show_details();
  247.  
  248.     int get_id();
  249. };
  250.  
  251. single::single(int id_number) {
  252.     bool online_mo;
  253.     int players;
  254.     int enemy_mo;
  255.     cout << "Liczba graczy:" << endl;
  256.     cin >> players;
  257.     cout << "Liczba przecieników:" << endl;
  258.     cin >> enemy_mo;
  259.     cout << "Czy gra jest online? (1 - tak, 0 - nie)" << endl;
  260.     cin >> online_mo;
  261.  
  262.     id = id_number;
  263.     number_of_players = players;
  264.     online = online_mo;
  265.     enemy = enemy_mo;
  266. }
  267.  
  268. single::~single() {
  269.     cout << "Objekt usunięty" << endl;
  270. }
  271.  
  272. int single::get_id() {
  273.     return id;
  274. }
  275.  
  276. void single::show_details() {
  277.  
  278.     cout << "Liczba graczy: " << number_of_players << "/n" << "Liczba przeciwników: " << enemy
  279.          << "/n";
  280.     if (online) {
  281.         cout << "Gra online" << endl;
  282.     } else {
  283.         cout << "Gra offline" << endl;
  284.     }
  285.  
  286. }
  287.  
  288. void mdo_h(list <single> objs, int id_number) {
  289.     for (std::list<single>::iterator it = objs.begin(); it != objs.end(); ++it) {
  290.         if(it->get_id() == id_number){
  291.             objs.remove(*it);
  292.         }
  293.     }
  294.     single obj(id_number);
  295.     objs.push_back(obj);
  296. }
  297.  
  298. class multi : public computer_game {
  299. private:
  300.     int id;
  301. protected:
  302.     int team;
  303. public:
  304.     multi(int);
  305.  
  306.     ~multi();
  307.  
  308.     void show_details();
  309.  
  310.     int get_id();
  311. };
  312.  
  313. multi::multi(int id_number) {
  314.     bool online_mo;
  315.     int players;
  316.     int team_mo;
  317.     cout << "Liczba graczy:" << endl;
  318.     cin >> players;
  319.     cout << "Liczba teamów:" << endl;
  320.     cin >> team_mo;
  321.     cout << "Czy gra jest online? (1 - tak, 0 - nie)" << endl;
  322.     cin >> online_mo;
  323.  
  324.     id = id_number;
  325.     number_of_players = players;
  326.     online = online_mo;
  327.     team = team_mo;
  328. }
  329.  
  330. multi::~multi() {
  331.     cout << "Objekt usunięty" << endl;
  332. }
  333.  
  334. int multi::get_id() {
  335.     return id;
  336. }
  337.  
  338. void multi::show_details() {
  339.  
  340.     cout << "Liczba graczy: " << number_of_players << "/n" << "Liczba teamów: " << team
  341.          << "/n";
  342.     if (online) {
  343.         cout << "Gra online" << endl;
  344.     } else {
  345.         cout << "Gra offline" << endl;
  346.     }
  347.  
  348. }
  349.  
  350. void mdo_i(list <multi> objs, int id_number) {
  351.     for (std::list<multi>::iterator it = objs.begin(); it != objs.end(); ++it) {
  352.         if(it->get_id() == id_number){
  353.             objs.remove(*it);
  354.         }
  355.     }
  356.     multi obj(id_number);
  357.     objs.push_back(obj);
  358. }
  359.  
  360.  
  361.  
  362. int main() {
  363.  
  364.     list <cooperative> e_objects;
  365.     list <individual> f_objects;
  366.     list <card> g_objects;
  367.     list <single> h_objects;
  368.     list <multi> i_objects;
  369.  
  370. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement