// Main loop. Sets class variables, and then asks bonus questions until user says "exit" void Question::runQuestionLoop(){ startingOptionsPrompt(); std::cout << std::endl << std::endl; // Loop ends when user enters "exit" as answer while(questioning){ generateQuestion(); } }
PTR_MESSAGE messageGenerateLen(MESSAGETYPE type, uint16_t length, void* content) { PTR_MESSAGE result; syslogSetLoglevel(7); result = NULL; switch(type) { case LoginRequest: result = generateLoginRequest(type, length, content); break; case LoginResponseOK: result = generateLoginResponseOK(type, length, content); break; case CatalogRequest: result = generateCatalogRequest(type, length, content); break; case CatalogResponse: result = generateCatalogResponse(type, length, content); break; case CatalogChange: result = generateCatalogChange(type, length, content); break; case PlayerList: result = generatePlayerList(type, length, content); break; case StartGame: result = generateStartGame(type, length, content); break; case QuestionRequest: result = generateQuestionRequest(type, length, content); break; case QUestion: result = generateQuestion(type, length, content); break; case QuestionAnswered: result = generateQuestionAnswered(type, length, content); break; case QuestionResult: result = generateQuestionResult(type, length, content); break; case GameOver: result = generateGameOver(type, length, content); break; case ErrorWarning: result = generateErrorWarning(type, length, content); break; } return result; }
int Arith::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: generateQuestion(); break; case 1: checkAnswer(); break; case 2: losePoints(); break; default: ; } _id -= 3; } return _id; }
int main(void) { initRandom(); warmGreeting(); const unsigned int numberOfQuestions = getNumberOfQuestions(); const difficulty difficulty = getDifficulty(); unsigned int correctAnswers = 0; string q, answer, userAnswer; for (unsigned int i = 1; i <= numberOfQuestions; i++) { puts(LINE_DIVIDER); printf("Question #%d\n", i); puts(LINE_DIVIDER); generateQuestion(q, 3 * difficulty, 25 * difficulty); getAnswer(q, answer); printf("%s = ", q); scanf("%s", userAnswer); if (strcmp(answer, userAnswer)) { printf("WRONG! answer=%s\n", answer); } else { correctAnswers++; printf("CORRECT!\n"); } } puts(LINE_DIVIDER); int p = (100 * correctAnswers) / numberOfQuestions; printf("TOTAL CORRECT ANSWERS = %d (%d%%)\n", correctAnswers, p); if (p >= 75) { switch (difficulty) { case EASY: puts("Good job, keep it up :)"); break; case MEDIUM: puts("Great job, you're on the way!"); break; case HARD: if (numberOfQuestions > 10) { puts("OMG! Amazing job! You are truly good at arithmetics! (unless you cheated...:P)"); } else { puts("WOW! Amazing job! I salute you"); } break; } } else if (p >= 50) { puts("Nice going, practice makes perfect ;)"); } else if (p >= 25) { puts("Keep practicing, don't give up!"); } else { puts("Better luck next time."); } standby(); return 0; }