#include #include "SquareT.h" #include using namespace std; using MapT = vector>; void MakeMap(MapT & map); void PrintMap(const MapT & map); void Describe(const MapT & map); int main() { char stop{'x'}; srand(time(nullptr)); MapT map(5, vector(10,nullptr)); MakeMap(map); while (stop != 'q') { PrintMap(map); Describe(map); cout << endl; cout << "Do you want to describe another sector (q to quit): "; cin >> stop; cout << endl << endl; } return 0; } void MakeMap(MapT & map) { size_t row,col; for( row = 0; row < map.size(); ++row) { for(col = 0; col < map[0].size(); ++col) { map[row][col] = RandomSquareT(); } } delete map[0][0]; map[0][0] = new WitchSquareT; } void PrintMap(const MapT & map){ cout << "+"; for (size_t i = 0; i < map[0].size(); ++i) { cout << "-"; } cout << "+" << endl; for(auto row = rbegin(map); row != rend(map); ++row) { cout << "|" ; for(auto & item : *row) { cout << item->GetRepresentation() ; } cout << "|"; cout << endl; } cout << "+"; for (size_t i = 0; i < map[0].size(); ++i) { cout << "-"; } cout << "+" << endl; } void Describe(const MapT & map) { size_t row, col; cout << "Enter a row (0 - " << map.size()-1 << "): "; cin >> row; cout << endl; cout << "Enter a column (0 - " << map[0].size()-1 << "): "; cin >> col; cout << endl; if (row < map.size() and col < map[0].size()) { map[row][col]->Explore(); cout << map[row][col]->Description() << endl; cout << "\tThe cost to enter is " << map[row][col]->Cost() << endl; if (auto tmp = dynamic_cast(map[row][col])) { cout << "\tThis is a road, the toll is " << tmp->Toll() << endl; } } cout << endl; }