Witam Państwa :)
Mam pytanie odnośnie dwóch klas bo nie do końca rozumiem jak one działają, jestem na etapie nauki związanej z OOP. Znalazłem kod programu,który bym chciał napisać w niedługiej przyszłości (w sumie to czas pokaże :D) i próbuję go sobie przyswoić/zrozumieć. Otóż w klasie Plane (chyba) nie ma nic o dziedziczeniu,czy jakiejś virtual _f ,a jednak Ona korzysta z klasy Ant. Ktoś mógłby mi podpowiedzieć ocb? Bo chyba znowu bd musiał się cofnąć z materiałem :/
#ifndef LANGTON_HPP_
#define LANGTON_HPP_
class Ant {
public:
// kierunki
enum Direction {
DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST
};
//konstruktor
Ant();
//destruktor
~Ant();
//skrecanie w lewo
void turnLeft();
void turnRight();
int getX();
int getY();
void setX(int x);
void setY(int y);
private:
Direction m_direction;//??
int m_x;
int m_y;
};
class Plane {
public:
/// The width of the plane.
static const int WIDTH = 500;
/// Height of the plane.
static const int HEIGHT = 200;
/// Is a space 'on'?
static const int ON = 1;
/// Is a space 'off'?
static const int OFF = 0;
Plane();
~Plane();
void setAnt(Ant*);
void flipColor(Ant*);
int getColorAt(Ant*);
int getWidth();
int getHeight();
void output();
void checkWrap();
void moveAnt();
private:
int m_plane[HEIGHT][WIDTH];
Ant* m_ant;
};
#endif /*LANGTON_HPP_*/