#include using namespace std; #include "whatstheface.h" #include "randgen.h" #include "strutils.h" // for LowerString WhatsTheQuestion::WhatsTheQuestion() : myPrompt("no questions") { } WhatsTheQuestion::WhatsTheQuestion(const string& prompt, const string& filename) { Open(prompt,filename); } void WhatsTheQuestion::Open(const string& prompt, const string& filename) { myPrompt = prompt; ifstream input(filename.c_str()); string first,second; while (getline(input,first) && getline(input,second)) { myQuestions.push_back(Quest(first,second)); } } void WhatsTheQuestion::Create() { RandGen gen; myQIndex = gen.RandInt(0,myQuestions.size()-1); } void WhatsTheQuestion::Ask() const { cout << myPrompt << " " << myQuestions[myQIndex].first << " : "; } bool WhatsTheQuestion::IsCorrect(const string& answer) const { return LowerString(answer) == LowerString(myQuestions[myQIndex].second); } string WhatsTheQuestion::Answer() const { return myQuestions[myQIndex].second; }