From d41730bc13eeb904d42ef0b03ef5317cb433eb39 Mon Sep 17 00:00:00 2001 From: fdlt3914 Date: Mon, 6 Feb 2023 15:41:49 +0000 Subject: [PATCH] provide introduction to enter game and exit --- src/main/quizproject.c | 25 ++++++++++++++++++++++++- src/main/quizproject.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index 4451a1f..9eaca58 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -181,6 +181,29 @@ void math_display_choice(){ } + +void math_enter_game() { + int choice = 0; + printf("\t\t-------------------------------------------------------\n"); + printf("\t\t Please enter 1 to start the game\n "); + printf("\t\t Please enter 0 to exit \n"); + printf("\t\t-------------------------------------------------------\n\n"); + printf("Enter your choice: "); + + scanf("%d", &choice); + switch (choice){ + // in order to start the game + case 1: + math_display_choice(); + break; + default: + printf("\t\t-------------------------------------------------------\n"); + printf("\t\t Sorry to see you go.\n "); + printf("\t\t-------------------------------------------------------\n\n"); + } + +} + //------------Math_quiz_end-------------- @@ -2175,7 +2198,7 @@ int main(int argc, char *argv[]) { jump_to_menu = 1; break; case 9: - math_display_choice(); + math_enter_game(); jump_to_menu = 1; break; case 10: diff --git a/src/main/quizproject.h b/src/main/quizproject.h index b1653f7..3aa3c25 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -41,6 +41,7 @@ void million_exit(int million_a); void math_choose_question(int); int math_answer(int); void math_display_choice(); +void math_enter_game(); //------Math_quiz_header_end-------