diff --git a/Question_driver.cpp b/Question_driver.cpp index c7c5ccaada27c40229986f7390fe777b9cf83e58..9abf4b6f7fc2a1f5d05c9cacb26e634756a33800 100644 --- a/Question_driver.cpp +++ b/Question_driver.cpp @@ -11,10 +11,10 @@ using namespace std; int main() { Questions questionList; - questionList.addSubQuestion(7); - questionList.addSubQuestion(7); - questionList.addSubQuestion(7); - questionList.addSubQuestion(7); + for(int i = 1; i <= 10; i++ ) { + questionList. mainQuestionAsk(i); + cout << "Level Up!\n"; + } return 0; } \ No newline at end of file diff --git a/Questions.cpp b/Questions.cpp index 60e3c8aaf75cc8d94a6bc6c28fcbf3112e72cd4c..17a8c4677028ff34dec0bdc3f2937b247e5bb9a2 100644 --- a/Questions.cpp +++ b/Questions.cpp @@ -10,15 +10,20 @@ #include // For time(0) using namespace std; -void Questions::mainQuestionAsk(int level) { - -} - -int Questions::determineQuestion(int level) { - return 0; +bool Questions::mainQuestionAsk(int level) { + if((level >= 1) && (level <= 3)) { + return countingQuestion(level); + } + else if ((level >= 4) && (level <= 10)) { + return addSubQuestion(level); + } + else { + return wordQuestion(level); + } } bool Questions::countingQuestion(int level) { + srand(time(0)); int countTo; switch(level) { case 1: @@ -32,9 +37,11 @@ bool Questions::countingQuestion(int level) { break; default: cerr << "Please see your teacher about your current level."; + return false; break; } int answer; + countTo++; //To set the possible range to 1 -> maximum, instead of 0 -> (maximum -1) for(int i = 0; i < countTo; i++) { if(countTo % 2 == 0) cout << "X "; @@ -83,6 +90,7 @@ bool Questions::addSubQuestion(int level) { break; default: cerr << "Please see your teacher about your current level.\n"; + return false; break; } @@ -138,5 +146,6 @@ bool Questions::addSubQuestion(int level) { } bool Questions::wordQuestion(int level) { - + cout << "Question type not configured."; + return false; } \ No newline at end of file diff --git a/Questions.h b/Questions.h index 9f2121f534d111eeb6fd2a2976ab9331337ee61c..792b447e38cbff256d1a7667d70866257c344735 100644 --- a/Questions.h +++ b/Questions.h @@ -2,6 +2,7 @@ Question class header file Jared Sexton ============================================================================ + Currently, questions are configured for levels 1 through 10. */ @@ -10,9 +11,9 @@ class Questions { public: - void mainQuestionAsk(int level); - - int determineQuestion(int level); + // Asks the proper question based on the player's level. + // It returns true if they answered correctly, and false if not. + bool mainQuestionAsk(int level); // Asks a question, returns true if the kid was right, false if they were wrong. bool countingQuestion(int level);