From f0b83f487f0dfce6ed452b921425cf258f2a3368 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 20:48:48 +0100 Subject: [PATCH] =?UTF-8?q?Entfernen=20eines=20ungenutzten=20formalen=20Pa?= =?UTF-8?q?rameters=20bei=20Funktion=20letterGuessed()=20und=20Hinzuf?= =?UTF-8?q?=C3=BCgen=20eines=20Counters,=20der=20die=20Anzahl=20der=20Rest?= =?UTF-8?q?versuche=20angibt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/hangman.c | 7 ++++--- src/main/c/Tim/hangman.h | 2 +- src/test/c/Tim/test_hangman.c | 12 ++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 799ceba..1a52a87 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -113,9 +113,10 @@ void hangman() break; } - if(!letterGuessed(userSelection, guessWord, length, displayWord)) + if(!letterGuessed(userSelection, guessWord, length)) { countWrongGuess++; + printf("Der von dir getippte Buchstabe war falsch! Du hast noch %d Versuche.\n", 6-countWrongGuess); } changeLetter(userSelection, guessWord, length, displayWord); drawHangman(countWrongGuess); @@ -152,7 +153,7 @@ bool wordGuessed(char x[], char y[]) } -bool letterGuessed(char x, char y[], int length, char ptr[]) +bool letterGuessed(char x, char y[], int length) { int counter = 0; for(int i = 0; i0) { - printf("Dein gewaehlter Buchstabe %c war ein Treffer!\n", x); + printf("Dein gewaehlter Buchstabe %c war ein Treffer! Du hast noch %d Versuche.\n", x); return true; } else diff --git a/src/main/c/Tim/hangman.h b/src/main/c/Tim/hangman.h index a258422..9a47b14 100644 --- a/src/main/c/Tim/hangman.h +++ b/src/main/c/Tim/hangman.h @@ -5,7 +5,7 @@ void hangman(); char* getWordFromList(int); bool wordGuessed(char[],char[]); -bool letterGuessed(char, char[], int, char[]); +bool letterGuessed(char, char[], int); void changeLetter(char, char[], int, char[]); void drawHangman(int); diff --git a/src/test/c/Tim/test_hangman.c b/src/test/c/Tim/test_hangman.c index e2b04da..757ed29 100644 --- a/src/test/c/Tim/test_hangman.c +++ b/src/test/c/Tim/test_hangman.c @@ -86,9 +86,8 @@ void test_letterGuessed_differentCaps_small_big() char x ='F'; char y[] ="Kartoffel"; int length = 9; - char z[] ="_________"; //assert - TEST_ASSERT_TRUE(letterGuessed(x,y,length,z)); + TEST_ASSERT_TRUE(letterGuessed(x,y,length)); } void test_letterGuessed_differentCaps_big_small() @@ -97,9 +96,8 @@ void test_letterGuessed_differentCaps_big_small() char x ='k'; char y[] ="Kartoffel"; int length = 9; - char z[] ="_________"; //assert - TEST_ASSERT_TRUE(letterGuessed(x,y,length,z)); + TEST_ASSERT_TRUE(letterGuessed(x,y,length)); } void test_letterGuessed_sameCaps_small() { @@ -107,9 +105,8 @@ void test_letterGuessed_sameCaps_small() char x ='f'; char y[] ="Kartoffel"; int length = 9; - char z[] ="_________"; //assert - TEST_ASSERT_TRUE(letterGuessed(x,y,length,z)); + TEST_ASSERT_TRUE(letterGuessed(x,y,length)); } void test_letterGuessed_sameCaps_big() @@ -118,8 +115,7 @@ void test_letterGuessed_sameCaps_big() char x ='K'; char y[] ="Kartoffel"; int length = 9; - char z[] ="_________"; //assert - TEST_ASSERT_TRUE(letterGuessed(x,y,length,z)); + TEST_ASSERT_TRUE(letterGuessed(x,y,length)); }