Browse Source

refactoring: Einführen der konstanten Variable POSSIBLE_TRYS

remotes/origin/tim
fdai7727 11 months ago
parent
commit
cbf15a5e39
  1. 6
      src/main/c/Tim/hangman.c

6
src/main/c/Tim/hangman.c

@ -10,6 +10,7 @@
#define MAX_WORD_LENGTH 30
#define STAGENUM 7
#define ASCII_ART_SIZE 1000
#define POSSIBLE_TRYS 6
char wordlist[LISTSIZE][MAX_WORD_LENGTH] = {
@ -87,7 +88,6 @@ void hangman()
int countWrongGuess=0;
strcpy(guessWord,getWordFromList(rand() % LISTSIZE));
length = strlen(guessWord);
printf("%s %d\n",guessWord, length);
char displayWord[MAX_WORD_LENGTH];
drawHangman(countWrongGuess);
@ -112,7 +112,7 @@ void hangman()
if(!letterGuessed(userSelection, guessWord, length))
{
countWrongGuess++;
printf("Der von dir getippte Buchstabe war falsch! Du hast noch %d Versuche.\n", 6-countWrongGuess);
printf("Der von dir getippte Buchstabe war falsch! Du hast noch %d Versuche.\n", POSSIBLE_TRYS-countWrongGuess);
}
if(userSelection == '0'||wordGuessed(guessWord, displayWord)||noTrysLeft(countWrongGuess))
{
@ -224,7 +224,7 @@ void drawHangman(int x)
bool noTrysLeft(int x)
{
if(x == 6)
if(x == POSSIBLE_TRYS)
{
printf("Du hast verloren!\n\n");
return true;

Loading…
Cancel
Save