|
|
@ -0,0 +1,87 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdbool.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include "casualQuiz.h" |
|
|
|
|
|
|
|
|
|
|
|
void casualQuiz() { |
|
|
|
printf("Print aus der Funktion Casual Quiz"); |
|
|
|
int index = 0; |
|
|
|
char* easy_fragen[] = { //eingabe der Fragen in ein Array |
|
|
|
"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?", |
|
|
|
}; |
|
|
|
char* easy_antworten[][4] = { //Eingabe der zugehörigen Antworten in ein array |
|
|
|
{"Elsa", "Rapunzel", "Cinderella", "Pocahontas"}, |
|
|
|
{"Republicanism", "Liberalism", "Conservatism", "Communism"}, |
|
|
|
}; |
|
|
|
int easy_richtigeAntworten[] = { 3,4}; // int, um die jeweils richtige antwort zu zeigen |
|
|
|
|
|
|
|
int length_frag_array = sizeof(easy_richtigeAntworten)/sizeof(int); |
|
|
|
int correct = 0; |
|
|
|
int answered = 0; |
|
|
|
int *correctP = &correct; |
|
|
|
int *answeredP = &answered; |
|
|
|
|
|
|
|
activePlaying(easy_fragen, *easy_antworten, easy_richtigeAntworten, length_frag_array, answeredP, correctP); |
|
|
|
printf("%d", answered); |
|
|
|
return; |
|
|
|
} |
|
|
|
void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size, int *answeredP, int *correctP ){ |
|
|
|
int eingabe; |
|
|
|
int plus = *answeredP +1; |
|
|
|
*answeredP = plus; |
|
|
|
for (int i = 0; i < size; i++){ |
|
|
|
eingabe = 5; |
|
|
|
FzeigeFragen(fragen, i); |
|
|
|
FzeigeAntworten(antworten, i); |
|
|
|
printf("Please type in your answer 1,2,3 or 4: "); |
|
|
|
eingabe = FEingabeInteger(); |
|
|
|
switch(eingabe){ |
|
|
|
case 1:{ |
|
|
|
printf("Case 1\n"); |
|
|
|
if (richtige_antwort[i] == 1) printf("Right Answer, well done.\n"); |
|
|
|
else printf("Wrong answer."); |
|
|
|
break; |
|
|
|
} |
|
|
|
case 2:{ |
|
|
|
printf("Case 2\n"); |
|
|
|
if (richtige_antwort[i] == 2) printf("Right Answer, well done.\n"); |
|
|
|
else printf("Wrong answer."); |
|
|
|
break; |
|
|
|
} |
|
|
|
case 3:{ |
|
|
|
printf("Case 3\n"); |
|
|
|
if (richtige_antwort[i] == 3) printf("Right Answer, well done.\n"); |
|
|
|
else printf("Wrong answer."); |
|
|
|
break; |
|
|
|
} |
|
|
|
case 4:{ |
|
|
|
printf("Case 4\n"); |
|
|
|
if (richtige_antwort[i] == 4) printf("Right Answer, well done.\n"); |
|
|
|
else printf("Wrong answer."); |
|
|
|
break; |
|
|
|
} |
|
|
|
default:{ |
|
|
|
printf("Wrong Input!"); |
|
|
|
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; |
|
|
|
} |