#include #include using namespace std; #include "tvector.h" #include "prompt.h" #include "randgen.h" #include "mathquestface.h" #include "whatstheface.h" // prototype quiz program for demonstrating inheritance void GiveQuestion(Question& quest) // post: quest is asked once, correct response is given { string answer; // cout << endl << quest.Description() << endl; cout << endl << "type answer after the question" << endl; quest.Create(); quest.Ask(); getline(cin,answer); if (quest.IsCorrect(answer)) { cout << "Excellent!, well done" << endl; } else { cout << "I'm sorry, the answer is " << quest.Answer() << endl; } } int main() { tvector questions; // fill with questions // questions.push_back(new MathQuestion()); // questions.push_back(new CarryMathQuestion()); questions.push_back(new HardMathQuestion()); questions.push_back(new WhatsTheQuestion("what's the capital of ", "c:\\data\\statequiz.dat")); questions.push_back(new WhatsTheQuestion("what artist made ", "c:\\data\\cdquiz.dat")); int qCount = PromptlnRange("how many questions",1,10); RandGen gen; int k; for(k=0; k < qCount; k++) { int index = gen.RandInt(0,questions.size()-1); GiveQuestion(*questions[index]); } for(k=0; k < questions.size(); k++) { delete questions[k]; } return 0; }