Browse Source

refactoring: Auslagern der Zähler, für mehr übersicht im Code

remotes/origin/Florian
Florian Baeseler 11 months ago
parent
commit
d58d71ddd1
  1. BIN
      build/test/out/c/casualQuiz.o
  2. BIN
      build/test/out/test_casualQuiz.out
  3. 2
      build/test/results/test_casualQuiz.pass
  4. 2
      build/test/results/test_quizduell.pass
  5. 2
      build/test/results/test_timequiz.pass
  6. 2
      build/test/results/test_wwm.pass
  7. 38
      src/casualQuiz.c
  8. 1
      src/casualQuiz.h

BIN
build/test/out/c/casualQuiz.o

BIN
build/test/out/test_casualQuiz.out

2
build/test/results/test_casualQuiz.pass

@ -45,4 +45,4 @@
- Right Answer, well done. - Right Answer, well done.
- Wrong Input! - Wrong Input!
- Wrong Input! - Wrong Input!
:time: 0.034674599999561906
:time: 0.03563229998690076

2
build/test/results/test_quizduell.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.013722000003326684
:time: 0.01542800001334399

2
build/test/results/test_timequiz.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.013790600001811981
:time: 0.015153000014834106

2
build/test/results/test_wwm.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.014121699990937486
:time: 0.014826200000243261

38
src/casualQuiz.c

@ -7,7 +7,7 @@
void casualQuiz() { void casualQuiz() {
printf("Print aus der Funktion Casual Quiz"); printf("Print aus der Funktion Casual Quiz");
int index = 0;
int index = 0;
char* easy_fragen[] = { //eingabe der Fragen in ein Array char* easy_fragen[] = { //eingabe der Fragen in ein Array
"Which Disney character famously leaves a glass shoe behind at a royal ball?", "Which Disney character famously leaves a glass shoe behind at a royal ball?",
"The hammer and sickle are one of the most recognisable symbols of which political ideology?", "The hammer and sickle are one of the most recognisable symbols of which political ideology?",
@ -16,18 +16,18 @@ void casualQuiz() {
{"Elsa", "Rapunzel", "Cinderella", "Pocahontas"}, {"Elsa", "Rapunzel", "Cinderella", "Pocahontas"},
{"Republicanism", "Liberalism", "Conservatism", "Communism"}, {"Republicanism", "Liberalism", "Conservatism", "Communism"},
}; };
int easy_richtigeAntworten[] = { 3,4}; // int, um die jeweils richtige antwort zu zeigen
int easy_richtigeAntworten[] = { 3,4 }; // int, um die jeweils richtige antwort zu zeigen
int length_frag_array = sizeof(easy_richtigeAntworten)/sizeof(int);
int length_frag_array = sizeof(easy_richtigeAntworten) / sizeof(int);
int correct = 0; int correct = 0;
int answered = 0; int answered = 0;
int *correctP = &correct;
int *answeredP = &answered;
int* correctP = &correct;
int* answeredP = &answered;
activePlaying(easy_fragen, *easy_antworten, easy_richtigeAntworten, length_frag_array, answeredP, correctP);
activePlaying(easy_fragen, *easy_antworten, easy_richtigeAntworten, length_frag_array, answeredP, correctP);
printf("korrekte Antworten: %d\n", correct); printf("korrekte Antworten: %d\n", correct);
printf("bei: %d beantworteten Fragen", answered); printf("bei: %d beantworteten Fragen", answered);
return;
return;
} }
void activePlaying(char* fragen[], char* antworten[], int richtige_antwort[], int size, int* answeredP, int* correctP) { void activePlaying(char* fragen[], char* antworten[], int richtige_antwort[], int size, int* answeredP, int* correctP) {
int eingabe; int eingabe;
@ -40,16 +40,7 @@ void activePlaying(char* fragen[], char* antworten[], int richtige_antwort[], in
printf("Please type in your answer 1,2,3 or 4: "); printf("Please type in your answer 1,2,3 or 4: ");
eingabe = FEingabeInteger(); eingabe = FEingabeInteger();
richtig = FcheckaufRichtigkeit(eingabe, richtige_antwort, i); richtig = FcheckaufRichtigkeit(eingabe, richtige_antwort, i);
if (richtig == true){
int plus = *answeredP + 1;
*answeredP = plus;
int add = *correctP + 1;
*correctP = add;
}
else{
int plus = *answeredP + 1;
*answeredP = plus;
}
FzaehlernachAuswahl(richtig, answeredP, correctP);
printf("Bool richtig / falsch: %d\n", richtig); printf("Bool richtig / falsch: %d\n", richtig);
printf(" %d\n", richtige_antwort[i]); printf(" %d\n", richtige_antwort[i]);
} }
@ -113,4 +104,17 @@ bool FcheckaufRichtigkeit(int eingabe, int richtige_antwort[], int i) {
} }
} }
return false; return false;
}
void FzaehlernachAuswahl(bool richtig, int* answeredP, int* correctP) {
if (richtig == true) {
int plus = *answeredP + 1;
*answeredP = plus;
int add = *correctP + 1;
*correctP = add;
}
else {
int plus = *answeredP + 1;
*answeredP = plus;
}
return;
} }

1
src/casualQuiz.h

@ -7,5 +7,6 @@ void FzeigeFragen(char *fragen[], int index);
void FzeigeAntworten(char *antworten[], int index); void FzeigeAntworten(char *antworten[], int index);
int FEingabeInteger(); int FEingabeInteger();
bool FcheckaufRichtigkeit(int eingabe, int richtige_antwort[],int i); bool FcheckaufRichtigkeit(int eingabe, int richtige_antwort[],int i);
void FzaehlernachAuswahl(bool richtig, int* answeredP, int* correctP);
#endif // ende CASUALQUIZ_H #endif // ende CASUALQUIZ_H
Loading…
Cancel
Save