School Commit Init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#include "service.h"
|
||||
#include <fstream>
|
||||
|
||||
void Service::addBuilding(Building* building){
|
||||
this->buildings.push_back(building);
|
||||
}
|
||||
|
||||
std::vector<Building*> Service::getAllBuildings(){
|
||||
return this->buildings;
|
||||
}
|
||||
|
||||
std::vector<Building*> Service::getAllToBeRestored(){
|
||||
std::vector<Building*> toBeRestored;
|
||||
for(auto building : this->buildings){
|
||||
if(building->mustBeRestored()){
|
||||
toBeRestored.push_back(building);
|
||||
}
|
||||
}
|
||||
return toBeRestored;
|
||||
}
|
||||
|
||||
std::vector<Building*> Service::getAllToBeDemolished(){
|
||||
std::vector<Building*> toBeDemolished;
|
||||
for(auto building : this->buildings){
|
||||
if(building->canBeDemolished()){
|
||||
toBeDemolished.push_back(building);
|
||||
}
|
||||
}
|
||||
return toBeDemolished;
|
||||
}
|
||||
|
||||
void Service::writeToFile(std::string fileName, std::vector<Building*> buildings){
|
||||
std::ofstream file(fileName);
|
||||
for(auto building : buildings){
|
||||
file << building->toString() << "\n";
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
Reference in New Issue
Block a user