#include #include #include #include #include "WarehouseT.h" #include "BuildingT.h" #include "ProductionBuildingT.h" #include "BonusBuildingT.h" #include "FarmT.h" #include "SawmillT.h" using namespace std; unique_ptr MakeBuilding(BuildingTypeT type, WarehouseT & warehouse) { switch(type) { case BuildingTypeT::FARM: return make_unique(warehouse); case BuildingTypeT::SAWMILL: return make_unique(warehouse); default: return nullptr; } } int main() { WarehouseT warehouse; size_t i; vector> buildings; buildings.push_back(MakeBuilding(BuildingTypeT::FARM, warehouse)); buildings.push_back(MakeBuilding(BuildingTypeT::FARM, warehouse)); buildings.push_back(MakeBuilding(BuildingTypeT::SAWMILL, warehouse)); // just to show that I can do this. buildings.push_back(nullptr); auto tmpPtr = make_unique(warehouse); buildings.back() = move(tmpPtr); warehouse.Wood(400); for(int time = 0; time < 3; time ++) { cout << "Time " << time << endl; for(i =0; i < buildings.size(); i++) { cout << "\tProduction in a " << buildings[i]->Type() << endl; auto prodPtr = dynamic_cast(buildings[i].get()); if (prodPtr != nullptr){ if (prodPtr->CanProduce()) { cout << "\t\tThe sector produced " << endl; prodPtr->Produce(); } } else { auto bonusPtr = dynamic_cast(buildings[i].get()); if (bonusPtr != nullptr) { cout << "\t\tExtra food Production " << bonusPtr->FoodBonus() << "%" << endl; cout << "\t\tExtra wood Production " << bonusPtr->WoodBonus() << "%" << endl; cout << "\t\tExtra gold Production " << bonusPtr->GoldBonus() << "%" << endl; } } } cout << endl; cout << "Current Warehouse " << endl; cout << "\tWood :" << warehouse.Wood(); cout << "\tConstruction:" << warehouse.Construction(); cout << endl; cout << endl; } cout << endl; return 0; }