From 89b622bb643e88503d30108e300dc187cccb106a Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:57:28 +0100 Subject: [PATCH] refactoring: Aufteilen der Funktion letterGuessed zu bool letterGuessed und changeLetter --- src/main/c/Tim/hangman.c | 44 +++++++++++++++++++++++++++++----------- src/main/c/Tim/hangman.h | 1 + 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 951e977..d77f46a 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -54,6 +54,7 @@ void hangman() scanf(" %c", &userSelection); letterGuessed(userSelection, guessWord, length, displayWord); + changeLetter(userSelection, guessWord, length, displayWord); printf("%s\n", displayWord); } @@ -90,6 +91,37 @@ bool wordGuessed(char x[], char y[]) bool letterGuessed(char x, char y[], int length, char ptr[]) { int counter = 0; + for(int i = 0; i0) + { + return true; + } + else + { + return false; + } + +} + + +void changeLetter(char x, char y[], int length, char ptr[]) +{ for(int i = 0; i0) - { - return true; } - else - { - return false; - } - } \ No newline at end of file diff --git a/src/main/c/Tim/hangman.h b/src/main/c/Tim/hangman.h index 9819b9a..ae68d97 100644 --- a/src/main/c/Tim/hangman.h +++ b/src/main/c/Tim/hangman.h @@ -6,5 +6,6 @@ void hangman(); char* getWordFromList(int); bool wordGuessed(char[],char[]); bool letterGuessed(char, char[], int, char[]); +void changeLetter(char, char[], int, char[]); #endif