#include #include "SquareT.h" using namespace std; BaseSquareT::BaseSquareT(char rep, int cost): travelCost{cost}, repChar {rep} {} string BaseSquareT::Description() const { return "An empty area"; } int BaseSquareT::Cost() const { return travelCost; } char BaseSquareT::GetRepresentation(){ if (hidden) { return '?'; } else { return repChar; } } void BaseSquareT::Explore() { hidden = false; } RoadSquareT::RoadSquareT(int cost, int toll): BaseSquareT{'_', cost}, tollPrice{toll} {} string RoadSquareT::Description() const { return "A road"; } int RoadSquareT::Toll() const { return tollPrice; } HillSquareT::HillSquareT(int cost): BaseSquareT{'^',cost} {} string HillSquareT::Description() const { return "A low hill"; } char HillSquareT::GetRepresentation(){ return repChar; } WitchSquareT::WitchSquareT(int cost): BaseSquareT{'x',cost} {} char WitchSquareT::GetRepresentation(){ return currentRep; } string WitchSquareT::Description() const { if (repChar == currentRep) { return "Ahh! a witch lives here."; } else { return "Not really sure"; } } void WitchSquareT::Explore(){ if (hidden) { // generate a % // if it is less than picts[0], type = ^ // if it is less than pcts[0]+pcts[1], type = - // else // type = x, hidden = false // decrease each pct value by .05 double roll = static_cast(rand())/RAND_MAX; if (roll < pcts[0]) { currentRep = '^'; } else if (roll < pcts[0] + pcts[1]) { currentRep = '-'; } else { currentRep = repChar; hidden = false; } pcts[0] -= .05; pcts[1] -= .05; } } BaseSquareT * RandomSquareT() { int type = rand() % 9; switch (type) { case 0: case 1: return new RoadSquareT; case 3: case 2: case 4: return new HillSquareT; case 5: case 6: case 7: case 8: default: return new BaseSquareT; } }