Browse Source

Mergecommitversuch2

main
Florian Baeseler 11 months ago
parent
commit
012e4ea669
  1. 0
      build/test/dependencies/force_build
  2. 2
      build/test/results/test_casualQuiz.pass
  3. 2
      build/test/results/test_quizduell.pass
  4. 2
      build/test/results/test_timequiz.pass
  5. 87
      src/casualQuiz.c
  6. 6
      src/casualQuiz.h

0
build/test/dependencies/force_build

2
build/test/results/test_casualQuiz.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.06824730001972057
:time: 0.027896299987332895

2
build/test/results/test_quizduell.pass

@ -51,4 +51,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.08023290001438
:time: 0.028896299976622686

2
build/test/results/test_timequiz.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.07155269998474978
:time: 0.029049100005067885

87
src/casualQuiz.c

@ -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;
}

6
src/casualQuiz.h

@ -2,7 +2,9 @@
#define CASUALQUIZ_H #define CASUALQUIZ_H
void casualQuiz(); void casualQuiz();
void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size, int *answeredP, int *correctP );
void FzeigeFragen(char *fragen[], int index);
void FzeigeAntworten(char *antworten[], int index);
int FEingabeInteger();
#endif // ende CASUALQUIZ_H #endif // ende CASUALQUIZ_H
Loading…
Cancel
Save