From 807861120fe530672771962d597eab3cd5c81d34 Mon Sep 17 00:00:00 2001 From: fdlt3885 Date: Wed, 8 Feb 2023 18:16:09 +0000 Subject: [PATCH] Added Guess the Animal Mini Game --- src/main/quizproject.c | 43 ++++++++++++++++++++++++++++++++++++++++-- src/main/quizproject.h | 3 +++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index a50288f..3edc7c0 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -2155,6 +2155,40 @@ void b_play_geography(){ } +//Guess animal Game + +void b_guess_animal() { + char animal[20]; + char user_input[20]; + printf("---Welcome to Guess The Animal---\n\n"); + printf("---Think of your favorite animal---\n\n"); + printf("Is it a wild animal? (yes/no)\n"); + scanf("%s", user_input); + + if (strcmp(user_input, "yes") == 0) { + printf("Does it live in the jungle? (yes/no)\n"); + scanf("%s", user_input); + + if (strcmp(user_input, "yes") == 0) { + strcpy(animal, "tiger"); + } else { + strcpy(animal, "gazelle"); + } + } else { + printf("Is it a domesticated animal? (yes/no)\n"); + scanf("%s", user_input); + + if (strcmp(user_input, "yes") == 0) { + strcpy(animal, "cat"); + } else { + strcpy(animal, "goldfish"); + } + } + + printf("Your favorite animal is a %s!\n", animal); + printf("---Thank you for Playing Guess The Animal---\n\n"); +} + void v_play_rockpapersciss(){ int player_choice, computer_choice, player_score = 0, computer_score = 0; @@ -2627,7 +2661,8 @@ int main(int argc, char *argv[]) { printf("9. Math Quiz\n"); printf("10. Check your Horoscope!\n"); printf("11. Play Geography Quiz!\n"); - printf("12. Exit\n"); + printf("12. Mini-Game: Guess the animal!\n"); + printf("13. Exit\n"); printf("Enter your choice: "); scanf("%d", &choice); v_progress_bar(argc,argv); @@ -2676,8 +2711,12 @@ int main(int argc, char *argv[]) { case 11: b_play_geography(); jump_to_menu = 1; - break; + break; case 12: + b_guess_animal(); + jump_to_menu = 1; + break; + case 13: printf("\nThank you for trying our C code!\n"); break; default: diff --git a/src/main/quizproject.h b/src/main/quizproject.h index c0c2b33..f444b3d 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -101,6 +101,9 @@ int b_askQuestion(int questionNumber, char* question, char* answer); void b_displayResults(int correctAnswers); void b_play_geography(); +//Guess animal Game Headers +void b_guess_animal(); + #define NUM_QUESTIONS 5 #define NUM_ROUNDS 15