From ffbf7437c12586edef8860e8e35d74cee1da4de8 Mon Sep 17 00:00:00 2001 From: Florian Baeseler Date: Tue, 6 Feb 2024 09:02:44 +0100 Subject: [PATCH] =?UTF-8?q?reactoring:=20Auslagerung=20der=20=C3=9Cberpr?= =?UTF-8?q?=C3=BCfung=20der=20Frage=20in=20eigene=20Funktion=20zur=20weite?= =?UTF-8?q?ren=20Verwendung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/test/out/test_quizduell.out | Bin 101212 -> 101212 bytes build/test/out/test_timequiz.out | Bin 101211 -> 101211 bytes build/test/out/test_wwm.out | Bin 101188 -> 101188 bytes build/test/results/test_casualQuiz.pass | 2 +- build/test/results/test_quizduell.pass | 2 +- build/test/results/test_timequiz.pass | 2 +- build/test/results/test_wwm.pass | 2 +- src/casualQuiz.c | 47 +++++++++++++----------- src/casualQuiz.h | 1 + 9 files changed, 31 insertions(+), 25 deletions(-) diff --git a/build/test/out/test_quizduell.out b/build/test/out/test_quizduell.out index 54daea90f3fe9d090a3920d4d98c999555dc0496..8ddd540eb0d9ceb5ba6ee7e5647a2d6b27f50f63 100755 GIT binary patch delta 25 hcmcaJjqT1fwh0}~ubv&8*zL;{WYTzR>n+BnE&!$D421vy delta 25 hcmcaJjqT1fwh0}~4BPfk?Dl0!V{W{)^%i4O7XXuk3rqk2 diff --git a/build/test/out/test_timequiz.out b/build/test/out/test_timequiz.out index dd25bdf4d85f1763a6f470119e8a286f5d06d59e..885477718376c23478706ffbcf048638111831f7 100755 GIT binary patch delta 25 hcmcaTjqUa{wh0}~ub&;9*zLz>P4Fv!I delta 25 hcmcaTjqUa{wh0}~4BPfk?Dl0^;?{U;>n+B{E&!L93(5ch diff --git a/build/test/out/test_wwm.out b/build/test/out/test_wwm.out index 23b11994d71e078c560a6860e2722c46e1871f25..38e54eedebc1edf2e9bc8aa91f8263d4f6b2536c 100755 GIT binary patch delta 25 hcmX>yjqS)Zwh0}~ub&;9*zL=t`@8Yh)?18OT>z#=4B!9& delta 25 hcmX>yjqS)Zwh0}~jNA54?Dl1HJk@w>>n+BtE&!9}3#R}8 diff --git a/build/test/results/test_casualQuiz.pass b/build/test/results/test_casualQuiz.pass index 43c95fa..c798cc5 100644 --- a/build/test/results/test_casualQuiz.pass +++ b/build/test/results/test_casualQuiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.027896299987332895 +:time: 0.0723504000052344 diff --git a/build/test/results/test_quizduell.pass b/build/test/results/test_quizduell.pass index 4fbcee0..b66751d 100644 --- a/build/test/results/test_quizduell.pass +++ b/build/test/results/test_quizduell.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.028896299976622686 +:time: 0.10005589999491349 diff --git a/build/test/results/test_timequiz.pass b/build/test/results/test_timequiz.pass index 4bfaa81..1e7dc4f 100644 --- a/build/test/results/test_timequiz.pass +++ b/build/test/results/test_timequiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.029049100005067885 +:time: 0.07419399998616427 diff --git a/build/test/results/test_wwm.pass b/build/test/results/test_wwm.pass index 2c5990d..16a6841 100644 --- a/build/test/results/test_wwm.pass +++ b/build/test/results/test_wwm.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.029695000004721805 +:time: 0.06791360001079738 diff --git a/src/casualQuiz.c b/src/casualQuiz.c index 20933cc..1ffb4a4 100644 --- a/src/casualQuiz.c +++ b/src/casualQuiz.c @@ -32,35 +32,56 @@ void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], in int eingabe; int plus = *answeredP +1; *answeredP = plus; + bool richtig; for (int i = 0; i < size; i++){ eingabe = 5; + richtig = false; FzeigeFragen(fragen, i); FzeigeAntworten(antworten, i); printf("Please type in your answer 1,2,3 or 4: "); eingabe = FEingabeInteger(); - switch(eingabe){ + richtig = FcheckaufRichtigkeit(eingabe, richtige_antwort, i); + printf(" %d\n", richtige_antwort[i]); + } +} +void FzeigeFragen(char *fragen[], int index){ + printf("Question: %s\n", fragen[index]); +} +void FzeigeAntworten(char *antworten[], int index){ + printf("1) %s\n", antworten[4 * index + 0]); + printf("2) %s\n", antworten[4 * index + 1]); + printf("3) %s\n", antworten[4 * index + 2]); + printf("4) %s\n", antworten[4 * index + 3]); +} +int FEingabeInteger(){ + int eingabeInt; + scanf_s("%d", &eingabeInt); + return eingabeInt; +} +bool FcheckaufRichtigkeit(int eingabe, int richtige_antwort[],int i){ + switch(eingabe){ case 1:{ printf("Case 1\n"); if (richtige_antwort[i] == 1) printf("Right Answer, well done.\n"); - else printf("Wrong answer."); + else printf("Wrong answer.\n"); break; } case 2:{ printf("Case 2\n"); if (richtige_antwort[i] == 2) printf("Right Answer, well done.\n"); - else printf("Wrong answer."); + else printf("Wrong answer.\n"); break; } case 3:{ printf("Case 3\n"); if (richtige_antwort[i] == 3) printf("Right Answer, well done.\n"); - else printf("Wrong answer."); + else printf("Wrong answer.\n"); break; } case 4:{ printf("Case 4\n"); if (richtige_antwort[i] == 4) printf("Right Answer, well done.\n"); - else printf("Wrong answer."); + else printf("Wrong answer.\n"); break; } default:{ @@ -68,20 +89,4 @@ void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], in break; } } - printf(" %d\n", richtige_antwort[i]); - } -} -void FzeigeFragen(char *fragen[], int index){ - printf("Question: %s\n", fragen[index]); -} -void FzeigeAntworten(char *antworten[], int index){ - printf("1) %s\n", antworten[4 * index + 0]); - printf("2) %s\n", antworten[4 * index + 1]); - printf("3) %s\n", antworten[4 * index + 2]); - printf("4) %s\n", antworten[4 * index + 3]); -} -int FEingabeInteger(){ - int eingabeInt; - scanf_s("%d", &eingabeInt); - return eingabeInt; } \ No newline at end of file diff --git a/src/casualQuiz.h b/src/casualQuiz.h index ae18d0f..55dff24 100644 --- a/src/casualQuiz.h +++ b/src/casualQuiz.h @@ -6,5 +6,6 @@ void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], in void FzeigeFragen(char *fragen[], int index); void FzeigeAntworten(char *antworten[], int index); int FEingabeInteger(); +bool FcheckaufRichtigkeit(int eingabe, int richtige_antwort[],int i); #endif // ende CASUALQUIZ_H