From 1e9b25047ac4d82a9ec2bf51a77840df3b7059c6 Mon Sep 17 00:00:00 2001 From: Pascal Gutermuth Date: Mon, 30 Jan 2023 18:31:43 +0100 Subject: [PATCH] =?UTF-8?q?Fragen=201-3=20f=C3=BCr=20Kategorie=20Fussball?= =?UTF-8?q?=20Level=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + build-project-windows-mingw.bat | 2 + build-project.sh | 2 + src/main.c | 92 +++++++++++++++++++++++++++++++++ team.md | 5 ++ 5 files changed, 102 insertions(+) create mode 100644 .gitignore create mode 100644 build-project-windows-mingw.bat create mode 100644 build-project.sh create mode 100644 src/main.c create mode 100644 team.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b3702a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Quiz-Game.exe \ No newline at end of file diff --git a/build-project-windows-mingw.bat b/build-project-windows-mingw.bat new file mode 100644 index 0000000..c177ca1 --- /dev/null +++ b/build-project-windows-mingw.bat @@ -0,0 +1,2 @@ +gcc src/main.c -o Quiz-Game +Quiz-Game.exe \ No newline at end of file diff --git a/build-project.sh b/build-project.sh new file mode 100644 index 0000000..52a949f --- /dev/null +++ b/build-project.sh @@ -0,0 +1,2 @@ +gcc src/main.c -o Quiz-Game +./Quiz-Game \ No newline at end of file diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..385c1b8 --- /dev/null +++ b/src/main.c @@ -0,0 +1,92 @@ +#include +#include + +typedef struct +{ + const char* question; + char answer[256]; +}Question; + +typedef struct +{ + int size; + Question questions[12]; +}Level; + +typedef struct +{ + int size; + const char* name; + Level lvlQuestions[10]; +}Category; + +int main() +{ + int score = 0; + int level = 0; + int maxLvl = 2; // definiert die Anzahl an Leveln + + char input[256]; + + Question fussQst1 = {.question = "Welche Fussballmannschaft wurde 1930 Weltmeister?", .answer = "Uruguay"}; + Question fussQst2 = {.question = "Welche Fussballmannschaft wurde 1934 Weltmeister?", .answer = "Italien"}; + Question fussQst3 = {.question = "Welche Fussballmannschaft wurde 1938 Weltmeister?", .answer = "Italien"}; + Level fussLevel1 = {.questions = {fussQst1, fussQst2, fussQst3}, .size = 3}; // size = anzahl an Fragen + + + + Category fussball = {.size = 2, .name = "Fussball", .lvlQuestions = {fussLevel1, }}; // size = anzahl an leveln in Kategorie + + Category categories[4] = + { + fussball, + }; + + printf("Willkommen beim Quiz-Spiel! Beantworten Sie die folgenden Fragen:\n"); + + int questCount = 0; + int curCatNum = 0; + int catCount = 1; // anzahl an kategorien + + for (int i = 0; i < catCount; i++) + { + Level lvlQuestions[10]; + memcpy(lvlQuestions, categories[i].lvlQuestions, sizeof(categories[i].lvlQuestions)); + + printf("Kategorie %s\n", categories[i].name); + + while (level < sizeof(lvlQuestions) / sizeof(Level)) + { + for (int i = 0; i < lvlQuestions[level].size; i++) + { + printf(lvlQuestions[level].questions[i].question); + printf(" "); + fgets(input, 256, stdin); + input[strlen(input) - 1] = '\0'; + const char* buf = lvlQuestions[level].questions[i].answer; + if (strcmp(input, buf)) + { + printf("Falsch. Die richtige Antwort ist: %s.\n", lvlQuestions[level].questions[i].answer); + } + else + { + printf("Richtig!\n"); + score++; + } + memset(&input[0], 0, sizeof(input)); + + questCount++; + } + + printf("Level %d abgeschlossen!\n", level + 1); + level++; + } + + level = 0; + } + + // Ergebnis + printf("Sie haben %d von %d Fragen richtig beantwortet.\n", score, questCount); + + return 0; +} \ No newline at end of file diff --git a/team.md b/team.md new file mode 100644 index 0000000..9b1eb8c --- /dev/null +++ b/team.md @@ -0,0 +1,5 @@ +# Committer: +Pascal Gutermuth, fdai7033, pascal.gutermuth@informatik.hs-fulda.de +Valentin Neumann, fdai7467, valentin.neumann@informatik.hs-fulda.de +Alexander Goller, fdai7403, alexander.goller@informatik.hs-fulda.de +Jan Thomas Schäfer, fdai6674, jan-thomas.schaefer@informatik.hs-fulda.de \ No newline at end of file