#include #include #include "PlayerT.h" #include "PesantT.h" #include "FighterT.h" #include "WizardT.h" #include "BattleMageT.h" using namespace std; int main() { srand(static_cast(time(nullptr))); vector players; WizardT * wizardPtr; FighterT * fighterPtr; players.push_back(new PesantT("Peter")); players.push_back(new FighterT("Fred")); players.push_back(new WizardT("Wanda")); players.push_back(new BattleMageT("Blake")); //for(auto x: players) { for(PlayerT * x: players) { cout << "*******************************************" << endl; // speak cout << x->Name() << " says \"" << x->Speak() << '"' << endl; cout << endl; // fight a bit. cout << "An attack by " << x->Name() << endl; cout << x->Fight() << endl; cout << x->Fight() << endl; cout << x->Fight() << endl; cout << x->Fight() << endl; cout << endl; // note that the dammage incured is different x->ChangeHP(-4); cout << x->Name() << " is injured for 4 points"; cout << " and now has " << x->HP() <<"/" << x->MaxHP() << endl; cout << endl; //x->Study(); wizardPtr = dynamic_cast(x); if (wizardPtr != nullptr) { cout << "Time to study " << wizardPtr->Study() << endl; } fighterPtr = dynamic_cast(x); if (fighterPtr != nullptr) { cout << "Time to workout " << fighterPtr->Workout() << endl; } cout << endl; } cout << "*******************************************" << endl; return 0; }