Advertisement
patas99

Untitled

Jan 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class vojak {
  5. private:
  6.     string barva;
  7.     string typ;
  8.     int x;
  9.     int y;
  10. public:
  11.     vojak(int _x, int _y) : x(_x), y(_y) { ; }
  12.     virtual void posun(int _x, int _y) = 0;
  13. };
  14.  
  15. class velitel : public vojak {
  16. private:
  17.     string barva = "cervena";
  18.     string typ = "velitel";
  19.     int x;
  20.     int y;
  21. public:
  22.     velitel(int _x, int _y) : vojak(_x, _y) { ; }
  23.     void posun(int _x, int _y) {
  24.         this->x = _x;
  25.         this->y = _y;
  26.     }
  27. };
  28.  
  29. class pesak : public vojak {
  30. private:
  31.     string barva = "zelena";
  32.     string typ = "pesak";
  33.     int x;
  34.     int y;
  35. public:
  36.     pesak(int _x, int _y) : vojak(_x, _y) { ; }
  37.     void posun(int _x, int _y) {
  38.         this->x = _x;
  39.         this->y = _y;
  40.     }
  41. };
  42. class delostrelec : public vojak {
  43. private:
  44.     string barva = "modra";
  45.     string typ = "delostrelec";
  46.     int x;
  47.     int y;
  48. public:
  49.     delostrelec(int _x, int _y) : vojak(_x, _y) { ; }
  50.     void posun(int _x, int _y) {
  51.         this->x = _x;
  52.         this->y = _y;
  53.     }
  54. };
  55. class ceta {
  56. private:
  57.     vojak **vojaci;
  58.     int x;
  59.     int y;
  60. public:
  61.     void setCeta(int pocetvojaku) {
  62.         this->vojaci = new vojak *[pocetvojaku];
  63.         for (int i = 0; i < pocetvojaku; i++) {
  64.             this->vojaci[i] = NULL;
  65.         }
  66.     }
  67.     void posun(int x, int y) {
  68.         this->x = x;
  69.         this->y = y;
  70.     }
  71. };
  72. class hrac {
  73. private:
  74.     vojak **vojaci;
  75.     ceta * cety;
  76.     unsigned int max;
  77. public:
  78.     hrac(int pocetVojaku)
  79.     {
  80.         this->max = pocetVojaku;
  81.         this->vojaci = new vojak *[pocetVojaku];
  82.         for (int i = 0; i < pocetVojaku; i++) {
  83.             this->vojaci[i] = NULL;
  84.         }
  85.     }
  86.     void pridej(vojak *vojak)
  87.     {
  88.         for (int i = 0; i < this->max; i++) {
  89.             this->vojaci[i] = vojak;
  90.         }
  91.     }
  92. };
  93. class hra {
  94. private:
  95.     hrac h1;
  96.     hrac h2;
  97. public:
  98.     void tahneH1() { ; }
  99.     void tahneH2() { ; }
  100. };
  101. int main(void)
  102. {
  103.     vojak *a = new pesak(1,2);
  104.     vojak *b = new delostrelec(2, 2);
  105.     vojak *c = new velitel(3, 3);
  106.     hrac *hrac1 = new hrac(2);
  107.     hrac1->pridej(a);
  108.     hrac1->pridej(b);
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement