From afaca42b31bad404e62af975bfdc77c7f477099d Mon Sep 17 00:00:00 2001 From: fdlt3859 Date: Sat, 28 Jan 2023 14:19:28 +0000 Subject: [PATCH] Created a Menu to add and run different programs --- src/main/quizproject.c | 45 ++++++++++++++++++++++++++++++++++++++++-- src/main/quizproject.h | 3 +++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index 3f75515..5c0a64f 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -4,6 +4,7 @@ #include #include #include "quizproject.h" + char answers[NUM_QUESTIONS] = {'B', 'A', 'A','B','A'}; int* randomNumber() { @@ -437,7 +438,7 @@ void displayThankYouMessage(void) { printf("*******************************\n\n"); } -int main(){ +void play_quizgame(void){ displayInstructions(); printf(">>Press 's' and Enter start the Game<<\n"); @@ -452,7 +453,47 @@ if (score > 2){ ask_hard_questions(); } displayThankYouMessage(); - return 0; +} + +void play_factorlie() { + printf("Playing game 2...\n"); + // code for game 2 goes here +} + +void play_game3() { + printf("Playing game 3...\n"); + // code for game 3 goes here +} + +int main() { + int choice; + + printf("Welcome to the Game Menu!\n"); + printf("1. QuizGame\n"); + printf("2. Fact or Lie?\n"); + printf("3. Game 3\n"); + printf("4. Exit\n"); + printf("Enter your choice: "); + scanf("%d", &choice); + + switch(choice) { + case 1: + play_quizgame(); + break; + case 2: + play_factorlie(); + break; + case 3: + play_game3(); + break; + case 4: + printf("Exiting the Game Menu...\n"); + break; + default: + printf("Invalid choice!\n"); + } + + return 0; } diff --git a/src/main/quizproject.h b/src/main/quizproject.h index fb61913..8a2964e 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -1,6 +1,9 @@ #ifndef QUIZPROJECT_H #define QUIZPROJECT_H +void play_quizgame(void); +void play_factorlie(void); +void play_game3(void); void displayWelcomeMessage(void); void displayGameInstructions(char vorName[], char nachName[]); void displayLifelineInstructions(void);