diff --git a/main.cpp b/main.cpp index dd917bc..369f57f 100644 --- a/main.cpp +++ b/main.cpp @@ -6,6 +6,9 @@ using namespace std; int main() { + ////////////////////////// + /// positions + ////////////////////////// cout << Position(2, 5) << endl; cout << Position(-1, 9) << endl; cout << Position(0, 0) << endl; @@ -25,6 +28,10 @@ int main() cout << (p1 == p2) << endl; cout << (p1 != p2) << endl; + ///////////////////////////// + /// tiles + ///////////////////////////// + auto t1 = Tile(p1, EMPTY); cout << t1.pos() << " -- type: " << t1.getType() << " -- traversable?: " << t1.traversable() << endl; @@ -33,5 +40,16 @@ int main() cout << t2.pos() << " -- type: " << t2.getType() << " -- traversable?: " << t2.traversable() << endl; + /* + * lack of flexibility in dynamic memory management for Tiles. If we don't know the number of tiles at compile-time, + * a fixed-size array is risky. Using vectors or linked lists, solves that problem, but we still have to manage + * memory deallocation by hand. + * + * as for Tiles having a Position member, having separate x_pos and y_pos int values for each Tile would eliminate + * the need for cting instances of Position. + * and it would spare us from having to overload operators, although in our case we're actually trying to + * practice that + */ + return 0; } diff --git a/tile/Tile.cpp b/tile/Tile.cpp index 0b1b9e7..3bce28b 100644 --- a/tile/Tile.cpp +++ b/tile/Tile.cpp @@ -13,7 +13,7 @@ Tile::Tile(Position pos, enum type type) : m_pos(pos), m_type(type) {} -type Tile::getType() const +const type Tile::getType() const { return m_type; } diff --git a/tile/Tile.h b/tile/Tile.h index 1c386e5..4869b54 100644 --- a/tile/Tile.h +++ b/tile/Tile.h @@ -8,7 +8,8 @@ #include "../position/Position.h" -enum type { +enum type +{ EMPTY, WALL }; @@ -23,13 +24,12 @@ public: explicit Tile(Position pos, type type); const Position &pos() const; - type getType() const; + + const type getType() const; bool traversable(); }; - - #endif //LABYRINTH_TILE_H