🎨 & 📝

main
Alexis Drai 2 years ago
parent 2a8a9d7150
commit 211a5ddb84

@ -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;
}

@ -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;
}

@ -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

Loading…
Cancel
Save