38 lines
981 B
C++
38 lines
981 B
C++
#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();
|
|
} |