Browse Source

Bool rüchgabe aus der Checkrichtig Funktion eingefügt

remotes/origin/Florian
Florian Baeseler 11 months ago
parent
commit
46b2927671
  1. 2
      build/test/results/test_casualQuiz.pass
  2. 2
      build/test/results/test_quizduell.pass
  3. 2
      build/test/results/test_timequiz.pass
  4. 2
      build/test/results/test_wwm.pass
  5. 129
      src/casualQuiz.c

2
build/test/results/test_casualQuiz.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0723504000052344
:time: 0.03847999998833984

2
build/test/results/test_quizduell.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.10005589999491349
:time: 0.040792099985992536

2
build/test/results/test_timequiz.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.07419399998616427
:time: 0.04975489998469129

2
build/test/results/test_wwm.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.06791360001079738
:time: 0.0336890000035055

129
src/casualQuiz.c

@ -28,65 +28,80 @@ void casualQuiz() {
printf("%d", answered); printf("%d", answered);
return; return;
} }
void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size, int *answeredP, int *correctP ){
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();
richtig = FcheckaufRichtigkeit(eingabe, richtige_antwort, i);
printf(" %d\n", richtige_antwort[i]);
}
void activePlaying(char* fragen[], char* antworten[], int richtige_antwort[], int size, int* answeredP, int* correctP) {
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();
richtig = FcheckaufRichtigkeit(eingabe, richtige_antwort, i);
printf("Bool richtig / falsch: %d\n", richtig);
printf(" %d\n", richtige_antwort[i]);
}
} }
void FzeigeFragen(char *fragen[], int index){
printf("Question: %s\n", fragen[index]);
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]);
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;
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.\n");
break;
}
case 2:{
printf("Case 2\n");
if (richtige_antwort[i] == 2) printf("Right Answer, well done.\n");
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.\n");
break;
}
case 4:{
printf("Case 4\n");
if (richtige_antwort[i] == 4) printf("Right Answer, well done.\n");
else printf("Wrong answer.\n");
break;
}
default:{
printf("Wrong Input!");
break;
}
}
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");
return true;
}
else printf("Wrong answer.\n");
break;
}
case 2: {
printf("Case 2\n");
if (richtige_antwort[i] == 2) {
printf("Right Answer, well done.\n");
return true;
}
else printf("Wrong answer.\n");
break;
}
case 3: {
printf("Case 3\n");
if (richtige_antwort[i] == 3) {
printf("Right Answer, well done.\n");
return true;
}
else printf("Wrong answer.\n");
break;
}
case 4: {
printf("Case 4\n");
if (richtige_antwort[i] == 4) {
printf("Right Answer, well done.\n");
return true;
}
else printf("Wrong answer.\n");
break;
}
default: {
printf("Wrong Input!");
return false;
break;
}
}
return false;
} }
Loading…
Cancel
Save