From 7981d1fb692df505ee359cc8234a6a9d957cf2ef Mon Sep 17 00:00:00 2001 From: Saba Fazlali Date: Thu, 8 Feb 2024 21:21:33 +0100 Subject: [PATCH] score added --- src/main/c/Hangman/playHangman.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/Hangman/playHangman.c b/src/main/c/Hangman/playHangman.c index 93d9998..68e34c0 100644 --- a/src/main/c/Hangman/playHangman.c +++ b/src/main/c/Hangman/playHangman.c @@ -11,6 +11,7 @@ char toLower(char ch) { void playHangman(char *wordToGuess) { int mistakes = 0; + int score = 10; char guessedLetters[30] = ""; //Guessed letters char currentGuess[50]; //Current state of the guessed word @@ -62,12 +63,14 @@ void playHangman(char *wordToGuess) { // Update mistakes (if the guess is wrong) if (!found) { mistakes++; + score--; } // Win: Check if the player guessed all the letters if (strcmp(currentGuess, wordToGuess) == 0) { currentState(currentGuess, mistakes); printf("Bravo! You guessed the word: %s \n", wordToGuess); + printf("your score is %d/10\n", score); printf("\n" " __ __ __ __ _ \n" " \\ \\ / /__ _ _ \\ \\ / /__ _ _ | |\n"