diff --git a/src/main/quizproject.c b/src/main/quizproject.c index 9478fb7..e086648 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -536,6 +536,46 @@ void play_guessingGame() { printf("****************************************\n"); } +void play_guessTheWord() { + char word[] = "Fulda"; + char guessed[MAX_WORD_LENGTH] = {0}; + int lives = MAX_LIVES; + int word_length = strlen(word); + char guess; + guess = toupper(guess); + + while (lives > 0) { + int i; + int correct = 0; + + printf("Lives: %d\n", lives); + printf("Guess a letter: "); + scanf(" %c", &guess); + + + for (i = 0; i < word_length; i++) { + if (word[i] == guess) { + guessed[i] = guess; + correct = 1; + } + } + + if (!correct) { + lives--; + } + + if (strcmp(word, guessed) == 0) { + printf("You win! The word was: %s\n", word); + break; + } + } + + if (lives == 0) { + printf("You lose! The word was: %s\n", word); + } + +} + void feedbackForm(void){ int rating; char feedback[1000]; @@ -591,13 +631,14 @@ int main() { int jump_to_menu = 0; - while (choice != 5 || jump_to_menu) { + while (choice != 6 || jump_to_menu) { printf("Welcome to the Game Menu!\n"); printf("1. QuizGame\n"); printf("2. Fact or Lie?\n"); printf("3. Who wants to be a millionaire\n"); printf("4. Guess the Number!\n"); - printf("5. Exit\n"); + printf("5. Guess the Word!\n"); + printf("6. Exit\n"); printf("Enter your choice: "); scanf("%d", &choice); @@ -619,6 +660,10 @@ int main() { jump_to_menu = 1; break; case 5: + play_guessTheWord(); + jump_to_menu = 1; + break; + case 6: printf("\nThank you for trying our C code!\n"); break; default: diff --git a/src/main/quizproject.h b/src/main/quizproject.h index 9dfb2c3..6850d0f 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -5,6 +5,7 @@ void play_quizgame(void); void play_factorlie(void); void play_milliongame(void); void play_guessingGame(void); +void play_guessTheWord(void); void displayWelcomeMessage(void); void displayGameInstructions(void); void displayLifelineInstructions(void); @@ -29,5 +30,7 @@ void v_guessingGame(void); #define NUM_QUESTIONS 5 #define round 3 +#define MAX_LIVES 10 +#define MAX_WORD_LENGTH 20 #endif