diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f8584cd..3b5107a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -16,7 +16,9 @@ // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-vscode.cpptools", - "ms-vscode.cmake-tools" + "ms-vscode.cmake-tools", + "ms-vscode.cpptools-extension-pack", + "franneck94.c-cpp-runner" ], // Use 'forwardPorts' to make a list of ports inside the container available locally. diff --git a/src/entity.cpp b/src/entity.cpp index b1c9930..d24c5cb 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -1,6 +1,7 @@ #include "header/entity.h" #include +#include namespace envlibcpp { Entity::Entity(std::string entityName) { @@ -36,10 +37,12 @@ namespace envlibcpp { } void Entity::setEnvironmentId(int id) { + std::cout << "Entity::setEnvironmentId()" << std::endl; environmentId = id; } void Entity::setGridId(int id) { + std::cout << "Entity::setGridId()" << std::endl; gridId = id; } diff --git a/src/environment.cpp b/src/environment.cpp index 0520dfe..3fd9b59 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1,5 +1,7 @@ #include "header/environment.h" +#include + namespace envlibcpp { Environment::Environment(std::string envName, int size) { id = rand() % 100 + 1; @@ -24,6 +26,7 @@ namespace envlibcpp { } void Environment::addEntity(Entity entity) { + std::cout << "Environment::addEntity()" << std::endl; entity.setEnvironmentId(id); grid.addEntity(entity); } diff --git a/src/grid.cpp b/src/grid.cpp index 63be070..c7775c8 100644 --- a/src/grid.cpp +++ b/src/grid.cpp @@ -4,9 +4,7 @@ namespace envlibcpp { Grid::Grid() { - id = rand() % 100 + 1; - size = 4; - generateLocations(); + Grid(4); } Grid::Grid(int gridSize) { @@ -24,6 +22,7 @@ namespace envlibcpp { } Location Grid::getFirstLocation() { + std::cout << "Grid::getFirstLocation()" << std::endl; return locations.front(); } @@ -69,8 +68,10 @@ namespace envlibcpp { } void Grid::addEntity(Entity entity) { + std::cout << "Grid::addEntity()" << std::endl; entity.setGridId(id); - getFirstLocation().addEntity(entity); + Location firstLocation = getFirstLocation(); + firstLocation.addEntity(entity); } void Grid::addEntityToLocation(Entity entity, Location location) { diff --git a/src/location.cpp b/src/location.cpp index fedbe8d..18f1e38 100644 --- a/src/location.cpp +++ b/src/location.cpp @@ -7,7 +7,6 @@ namespace envlibcpp { id = rand() % 100 + 1; x = xpos; y = ypos; - } int Location::getId() { @@ -27,6 +26,7 @@ namespace envlibcpp { } void Location::addEntity(Entity entity) { + std::cout << "Location::addEntity()" << std::endl; entity.setLocationId(getId()); entities.push_back(entity); } diff --git a/src/tests.cpp b/src/tests.cpp index 4403030..f99cbaa 100644 --- a/src/tests.cpp +++ b/src/tests.cpp @@ -12,7 +12,9 @@ void testGridGeneration() { std::cout << "Test - Grid Generation" << std::endl; int size = 4; Environment environment("test environment", 4); - assert(environment.getGrid().getLocations().size() == size*size); + int numLocations = environment.getGrid().getLocations().size(); + int expectedNumLocations = size*size; + assert(numLocations == expectedNumLocations); std::cout << "Success" << std::endl; } @@ -21,8 +23,10 @@ void testEntityPlacement() { std::cout << "Test - Entity Placement" << std::endl; Entity entity("Daniel"); Environment environment("Earth", 2); + environment.addEntity(entity); - assert(environment.getNumEntities() > 0); + + assert(environment.isEntityPresent(entity) == true); std::cout << "Success" << std::endl; }