From a9cc69fbb2a81e3f950eb05c4f2eefaa910774a4 Mon Sep 17 00:00:00 2001 From: Pascal Schneider Date: Tue, 6 Feb 2024 21:45:13 +0100 Subject: [PATCH] =?UTF-8?q?refactoring:=20Kommentare=20f=C3=BCr=20Spiel=20?= =?UTF-8?q?hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/timequiz.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/timequiz.c b/src/timequiz.c index bf6562a..83f2be0 100644 --- a/src/timequiz.c +++ b/src/timequiz.c @@ -8,6 +8,7 @@ #define ASKED_QUESTIONS 40 +//Funktionen des Codes void timequiz(); int getRandomQuestionIndex(int askedQuestions[], int totalQuestions); @@ -18,8 +19,11 @@ void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalC int isValidAnswer(int userAnswer); + + void timequiz() { +//Willkommensnachricht printf("Welcome to our Time Quiz!\n"); printf("You have 60 seconds to answer the questions. Have fun!\n"); @@ -132,7 +136,7 @@ void timequiz() { correctAnswers[i] = 4; } } - +//Variablen für das Spiel int score = 0; int totalAnsweredQuestions = 0; int totalCorrectAnswers = 0; @@ -145,6 +149,7 @@ void timequiz() { memset(askedQuestions, 0, sizeof(askedQuestions)); srand((unsigned int)time(NULL)); +//While-Schleife für Spielausführung while (elapsedTime < 60 && totalAnsweredQuestions < totalQuestions) { int questionIndex = getRandomQuestionIndex(askedQuestions, totalQuestions); askedQuestions[questionIndex] = 1; @@ -169,6 +174,7 @@ void timequiz() { elapsedTime = (int)difftime(currentTime, startTime); } +//Endnachricht printf("\nQuiz finished!\n"); printf("Your total score: %d out of %d\n", totalCorrectAnswers, totalAnsweredQuestions); }