From 85e964a02340b61dc5de88ebb4058bf0439e4173 Mon Sep 17 00:00:00 2001 From: Pascal Schneider Date: Tue, 6 Feb 2024 21:54:18 +0100 Subject: [PATCH] =?UTF-8?q?refactoring:=20Gesamtscorefunktion=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/timequiz.c | 12 ++++++++++-- src/timequiz.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/timequiz.c b/src/timequiz.c index 9f22db7..f71806e 100644 --- a/src/timequiz.c +++ b/src/timequiz.c @@ -19,6 +19,8 @@ void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalC int isValidAnswer(int userAnswer); +void printQuizResult(int totalCorrectAnswers, int totalAnsweredQuestions); + void timequiz() { @@ -175,9 +177,9 @@ void timequiz() { } //Endnachricht - printf("\nQuiz finished!\n"); - printf("Your total score: %d out of %d\n", totalCorrectAnswers, totalAnsweredQuestions); + printQuizResult(totalCorrectAnswers, totalAnsweredQuestions); } + //Zufällige Frage auswählen int getRandomQuestionIndex(int askedQuestions[], int totalQuestions) { int questionIndex; @@ -208,3 +210,9 @@ void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalC int isValidAnswer(int userAnswer) { return (userAnswer >= 1 && userAnswer <= 4); } +//Ausgabe Endscore +void printQuizResult(int totalCorrectAnswers, int totalAnsweredQuestions) { + printf("\nQuiz finished!\n"); + printf("Your total score: %d out of %d\n", totalCorrectAnswers, totalAnsweredQuestions); +} + diff --git a/src/timequiz.h b/src/timequiz.h index ca65f16..19eff23 100644 --- a/src/timequiz.h +++ b/src/timequiz.h @@ -6,5 +6,6 @@ int getRandomQuestionIndex(int askedQuestions[], int totalQuestions); void displayQuestion(const char* question,const char* answers[], int correctIndex); void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers,const char* answers[]); int isValidAnswer(int userAnswer); +void printQuizResult(int totalCorrectAnswers, int totalAnsweredQuestions); #endif //ende TIMEQUIZ_H