From a93340bfbcc65671667137b5d868ba406fad4c5d Mon Sep 17 00:00:00 2001 From: Christian Reum Date: Tue, 6 Feb 2024 21:08:54 +0100 Subject: [PATCH] refactoring 10: Fragenarray Umbenennung zu easy, medium, hard zur besseren Findung --- src/wwm.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/wwm.c b/src/wwm.c index e6f3577..40482f2 100644 --- a/src/wwm.c +++ b/src/wwm.c @@ -26,7 +26,7 @@ int crandomNumber() { } - +// Überprüft Antwort auf 5 und Zahlen kleiner als 1 oder größer als 4 void ccheckAnswer(int useranswer) { if (useranswer == 5) { printf("That is a shame, but ok.\n"); @@ -39,6 +39,7 @@ void ccheckAnswer(int useranswer) { } } +// Eingabe mit Pürfung auf integer int ceingabe() { printf("Your answer (1-4):"); int result = scanf("%d", &useranswer); @@ -57,7 +58,7 @@ void wwm(){ printf("Choose your answer with the numbers 1-4! \n"); printf("If you want to stop and take the money, type in 5!\n"); - const char* question[] = { + const char* question_easy[] = { "Which planet is known as the `blue planet`?", "What is the capital of Germany?", "What is the largest desert in the world?", @@ -70,7 +71,7 @@ void wwm(){ "What is the largest planet in our solar system?" }; - const char* answers[][4] = { + const char* answers_easy[][4] = { {"Mars", "Venus", "Earth", "Jupiter"}, {"Munich", "Berlin", "Cologne", "Frankfurt am Main"}, {"Antarctica", "Sahara", "Gobi", "Arctica" }, @@ -83,12 +84,12 @@ void wwm(){ {"Merkur", "Jupiter", "Neptun", "Pluto"} }; - int correctAnswer[] = { + int correctAnswer_easy[] = { 3, 2, 1, 2, 4, 2, 1, 3, 1, 2 }; - const char* questions2[] = { + const char* questions_medium[] = { "In what year did the Berlin Wall fall?", "What is the capital city of Brazil?", "Who is known as the Father of Modern Physics?", @@ -96,7 +97,7 @@ void wwm(){ "What is the chemical symbol for silver?" }; - const char* answers2[][4] = { + const char* answers_medium[][4] = { {"1989", "1998", "1994", "1990"}, {"Buenos Aires", "Sao Paulo", "Brasilia", "Rio de Janeiro"}, {"Thomas Edison", "Marie Curie", "Isaac Newton", "Albert Einstein"}, @@ -104,11 +105,11 @@ void wwm(){ {"Au", "Ag", "Su", "Si"} }; - int correctAnswer2[] = { + int correctAnswer_medium[] = { 1, 3, 4, 2, 2 }; - const char* questions3[] = { + const char* questions_hard[] = { "What is the rarest blood type among humans?", "In which year did Serena Williams win her first Grand Slam singles title?", "In what year and in which city were the first modern Olympic Games held?", @@ -116,7 +117,7 @@ void wwm(){ "What is the capital city of Bhutan?" }; - const char* answers3[][4] = { + const char* answers_hard[][4] = { {"A", "B", "0", "AB"}, {"1999", "1995", "2000", "2002"}, {"1894 in Rome, Italy", "1896 in Athens, Greece", "1898 in Madrid, Spain", "1890 in Istanbul, Turkey"}, @@ -124,7 +125,7 @@ void wwm(){ {"Paro", "Punakha", "Thimphu", "Tongsa"} }; - int correctAnswer3[] = { + int correctAnswer_hard[] = { 4, 1, 2, 1, 3 }; @@ -138,16 +139,16 @@ void wwm(){ printf("__________________________________________________ \n\n"); printf("You are at stage %d and have %d $\n", runde, geld); crandomNumber(); - printf("Question %d: %s\n", runde + 1, question[frage]); + printf("Question %d: %s\n", runde + 1, question_easy[frage]); for (int i = 0; i < 4; i++) { - printf("%d. %s \n", i + 1, answers[frage][i]); + printf("%d. %s \n", i + 1, answers_easy[frage][i]); } ceingabe(); - if (useranswer == correctAnswer[frage]) { + if (useranswer == correctAnswer_easy[frage]) { printf("That is correct!\n"); runde++; setGeld(runde); @@ -162,15 +163,15 @@ void wwm(){ printf("___________________________________________________________\n\n"); printf("You are at stage %d and have %d $\n", runde + 1, geld); crandomNumber(); - printf("Question %d: %s\n", runde + 1, questions2[frage]); + printf("Question %d: %s\n", runde + 1, questions_medium[frage]); for (int i = 0; i < 4; i++) { - printf("%d. %s \n", i + 1, answers2[frage][i]); + printf("%d. %s \n", i + 1, answers_medium[frage][i]); }; ceingabe(); - if (useranswer == correctAnswer2[frage]) { + if (useranswer == correctAnswer_medium[frage]) { printf("That is correct!\n"); runde++; setGeld(runde); @@ -185,15 +186,15 @@ void wwm(){ printf("___________________________________________________________\n\n"); printf("You are at stage %d and have %d $\n", runde + 1, geld); crandomNumber(); - printf("Question %d: %s\n", runde + 1, questions3[frage]); + printf("Question %d: %s\n", runde + 1, questions_hard[frage]); for (int i = 0; i < 4; i++) { - printf("%d. %s \n", i + 1, answers3[frage][i]); + printf("%d. %s \n", i + 1, answers_hard[frage][i]); }; ceingabe(); - if (useranswer == correctAnswer3[frage]) { + if (useranswer == correctAnswer_hard[frage]) { printf("That is correct!\n"); runde++; setGeld(runde);