Browse Source

refactoring 10: Fragenarray Umbenennung zu easy, medium, hard zur besseren Findung

remotes/origin/Christian
Christian Reum 11 months ago
parent
commit
a93340bfbc
  1. 39
      src/wwm.c

39
src/wwm.c

@ -26,7 +26,7 @@ int crandomNumber() {
} }
// Überprüft Antwort auf 5 und Zahlen kleiner als 1 oder größer als 4
void ccheckAnswer(int useranswer) { void ccheckAnswer(int useranswer) {
if (useranswer == 5) { if (useranswer == 5) {
printf("That is a shame, but ok.\n"); printf("That is a shame, but ok.\n");
@ -39,6 +39,7 @@ void ccheckAnswer(int useranswer) {
} }
} }
// Eingabe mit Pürfung auf integer
int ceingabe() { int ceingabe() {
printf("Your answer (1-4):"); printf("Your answer (1-4):");
int result = scanf("%d", &useranswer); int result = scanf("%d", &useranswer);
@ -57,7 +58,7 @@ void wwm(){
printf("Choose your answer with the numbers 1-4! \n"); printf("Choose your answer with the numbers 1-4! \n");
printf("If you want to stop and take the money, type in 5!\n"); printf("If you want to stop and take the money, type in 5!\n");
const char* question[] = {
const char* question_easy[] = {
"Which planet is known as the `blue planet`?", "Which planet is known as the `blue planet`?",
"What is the capital of Germany?", "What is the capital of Germany?",
"What is the largest desert in the world?", "What is the largest desert in the world?",
@ -70,7 +71,7 @@ void wwm(){
"What is the largest planet in our solar system?" "What is the largest planet in our solar system?"
}; };
const char* answers[][4] = {
const char* answers_easy[][4] = {
{"Mars", "Venus", "Earth", "Jupiter"}, {"Mars", "Venus", "Earth", "Jupiter"},
{"Munich", "Berlin", "Cologne", "Frankfurt am Main"}, {"Munich", "Berlin", "Cologne", "Frankfurt am Main"},
{"Antarctica", "Sahara", "Gobi", "Arctica" }, {"Antarctica", "Sahara", "Gobi", "Arctica" },
@ -83,12 +84,12 @@ void wwm(){
{"Merkur", "Jupiter", "Neptun", "Pluto"} {"Merkur", "Jupiter", "Neptun", "Pluto"}
}; };
int correctAnswer[] = {
int correctAnswer_easy[] = {
3, 2, 1, 2, 4, 2, 1, 3, 1, 2 3, 2, 1, 2, 4, 2, 1, 3, 1, 2
}; };
const char* questions2[] = {
const char* questions_medium[] = {
"In what year did the Berlin Wall fall?", "In what year did the Berlin Wall fall?",
"What is the capital city of Brazil?", "What is the capital city of Brazil?",
"Who is known as the Father of Modern Physics?", "Who is known as the Father of Modern Physics?",
@ -96,7 +97,7 @@ void wwm(){
"What is the chemical symbol for silver?" "What is the chemical symbol for silver?"
}; };
const char* answers2[][4] = {
const char* answers_medium[][4] = {
{"1989", "1998", "1994", "1990"}, {"1989", "1998", "1994", "1990"},
{"Buenos Aires", "Sao Paulo", "Brasilia", "Rio de Janeiro"}, {"Buenos Aires", "Sao Paulo", "Brasilia", "Rio de Janeiro"},
{"Thomas Edison", "Marie Curie", "Isaac Newton", "Albert Einstein"}, {"Thomas Edison", "Marie Curie", "Isaac Newton", "Albert Einstein"},
@ -104,11 +105,11 @@ void wwm(){
{"Au", "Ag", "Su", "Si"} {"Au", "Ag", "Su", "Si"}
}; };
int correctAnswer2[] = {
int correctAnswer_medium[] = {
1, 3, 4, 2, 2 1, 3, 4, 2, 2
}; };
const char* questions3[] = {
const char* questions_hard[] = {
"What is the rarest blood type among humans?", "What is the rarest blood type among humans?",
"In which year did Serena Williams win her first Grand Slam singles title?", "In which year did Serena Williams win her first Grand Slam singles title?",
"In what year and in which city were the first modern Olympic Games held?", "In what year and in which city were the first modern Olympic Games held?",
@ -116,7 +117,7 @@ void wwm(){
"What is the capital city of Bhutan?" "What is the capital city of Bhutan?"
}; };
const char* answers3[][4] = {
const char* answers_hard[][4] = {
{"A", "B", "0", "AB"}, {"A", "B", "0", "AB"},
{"1999", "1995", "2000", "2002"}, {"1999", "1995", "2000", "2002"},
{"1894 in Rome, Italy", "1896 in Athens, Greece", "1898 in Madrid, Spain", "1890 in Istanbul, Turkey"}, {"1894 in Rome, Italy", "1896 in Athens, Greece", "1898 in Madrid, Spain", "1890 in Istanbul, Turkey"},
@ -124,7 +125,7 @@ void wwm(){
{"Paro", "Punakha", "Thimphu", "Tongsa"} {"Paro", "Punakha", "Thimphu", "Tongsa"}
}; };
int correctAnswer3[] = {
int correctAnswer_hard[] = {
4, 1, 2, 1, 3 4, 1, 2, 1, 3
}; };
@ -138,16 +139,16 @@ void wwm(){
printf("__________________________________________________ \n\n"); printf("__________________________________________________ \n\n");
printf("You are at stage %d and have %d $\n", runde, geld); printf("You are at stage %d and have %d $\n", runde, geld);
crandomNumber(); crandomNumber();
printf("Question %d: %s\n", runde + 1, question[frage]);
printf("Question %d: %s\n", runde + 1, question_easy[frage]);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
printf("%d. %s \n", i + 1, answers[frage][i]);
printf("%d. %s \n", i + 1, answers_easy[frage][i]);
} }
ceingabe(); ceingabe();
if (useranswer == correctAnswer[frage]) {
if (useranswer == correctAnswer_easy[frage]) {
printf("That is correct!\n"); printf("That is correct!\n");
runde++; runde++;
setGeld(runde); setGeld(runde);
@ -162,15 +163,15 @@ void wwm(){
printf("___________________________________________________________\n\n"); printf("___________________________________________________________\n\n");
printf("You are at stage %d and have %d $\n", runde + 1, geld); printf("You are at stage %d and have %d $\n", runde + 1, geld);
crandomNumber(); crandomNumber();
printf("Question %d: %s\n", runde + 1, questions2[frage]);
printf("Question %d: %s\n", runde + 1, questions_medium[frage]);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
printf("%d. %s \n", i + 1, answers2[frage][i]);
printf("%d. %s \n", i + 1, answers_medium[frage][i]);
}; };
ceingabe(); ceingabe();
if (useranswer == correctAnswer2[frage]) {
if (useranswer == correctAnswer_medium[frage]) {
printf("That is correct!\n"); printf("That is correct!\n");
runde++; runde++;
setGeld(runde); setGeld(runde);
@ -185,15 +186,15 @@ void wwm(){
printf("___________________________________________________________\n\n"); printf("___________________________________________________________\n\n");
printf("You are at stage %d and have %d $\n", runde + 1, geld); printf("You are at stage %d and have %d $\n", runde + 1, geld);
crandomNumber(); crandomNumber();
printf("Question %d: %s\n", runde + 1, questions3[frage]);
printf("Question %d: %s\n", runde + 1, questions_hard[frage]);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
printf("%d. %s \n", i + 1, answers3[frage][i]);
printf("%d. %s \n", i + 1, answers_hard[frage][i]);
}; };
ceingabe(); ceingabe();
if (useranswer == correctAnswer3[frage]) {
if (useranswer == correctAnswer_hard[frage]) {
printf("That is correct!\n"); printf("That is correct!\n");
runde++; runde++;
setGeld(runde); setGeld(runde);

Loading…
Cancel
Save