Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class vojak {
- private:
- string barva;
- string typ;
- int x;
- int y;
- public:
- vojak(int _x, int _y) : x(_x), y(_y) { ; }
- virtual void posun(int _x, int _y) = 0;
- };
- class velitel : public vojak {
- private:
- string barva = "cervena";
- string typ = "velitel";
- int x;
- int y;
- public:
- velitel(int _x, int _y) : vojak(_x, _y) { ; }
- void posun(int _x, int _y) {
- this->x = _x;
- this->y = _y;
- }
- };
- class pesak : public vojak {
- private:
- string barva = "zelena";
- string typ = "pesak";
- int x;
- int y;
- public:
- pesak(int _x, int _y) : vojak(_x, _y) { ; }
- void posun(int _x, int _y) {
- this->x = _x;
- this->y = _y;
- }
- };
- class delostrelec : public vojak {
- private:
- string barva = "modra";
- string typ = "delostrelec";
- int x;
- int y;
- public:
- delostrelec(int _x, int _y) : vojak(_x, _y) { ; }
- void posun(int _x, int _y) {
- this->x = _x;
- this->y = _y;
- }
- };
- class ceta {
- private:
- vojak **vojaci;
- int x;
- int y;
- public:
- void setCeta(int pocetvojaku) {
- this->vojaci = new vojak *[pocetvojaku];
- for (int i = 0; i < pocetvojaku; i++) {
- this->vojaci[i] = NULL;
- }
- }
- void posun(int x, int y) {
- this->x = x;
- this->y = y;
- }
- };
- class hrac {
- private:
- vojak **vojaci;
- ceta * cety;
- unsigned int max;
- public:
- hrac(int pocetVojaku)
- {
- this->max = pocetVojaku;
- this->vojaci = new vojak *[pocetVojaku];
- for (int i = 0; i < pocetVojaku; i++) {
- this->vojaci[i] = NULL;
- }
- }
- void pridej(vojak *vojak)
- {
- for (int i = 0; i < this->max; i++) {
- this->vojaci[i] = vojak;
- }
- }
- };
- class hra {
- private:
- hrac h1;
- hrac h2;
- public:
- void tahneH1() { ; }
- void tahneH2() { ; }
- };
- int main(void)
- {
- vojak *a = new pesak(1,2);
- vojak *b = new delostrelec(2, 2);
- vojak *c = new velitel(3, 3);
- hrac *hrac1 = new hrac(2);
- hrac1->pridej(a);
- hrac1->pridej(b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement