Browse Source
Merge branch 'Saba' into 'main'
Merge branch 'Saba' into 'main'
adding more features See merge request pmuw_projekt/pmuw_projekt_notebinder!39remotes/origin/Saba
fdai7875
11 months ago
9 changed files with 146 additions and 29 deletions
-
7.idea/vcs.xml
-
3src/main/c/Hangman/drawHangman.h
-
5src/main/c/Hangman/initializeHangman.h
-
26src/main/c/Hangman/playHangman.c
-
12src/main/c/Hangman/playHangman.h
-
93src/main/c/Hangman/word_selector.c
-
4src/main/c/Hangman/word_selector.h
-
2src/main/c/main.c
-
23test/Hangman/test_initializeHangman.c
@ -0,0 +1,7 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="VcsDirectoryMappings"> |
||||
|
<mapping directory="" vcs="Git" /> |
||||
|
<mapping directory="$PROJECT_DIR$/Unity" vcs="Git" /> |
||||
|
</component> |
||||
|
</project> |
@ -1,33 +1,92 @@ |
|||||
#include "word_selector.h" |
#include "word_selector.h" |
||||
|
|
||||
const char wordsList[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
|
||||
"skill", |
|
||||
|
// easy words |
||||
|
char wordsList_easy[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
||||
|
"apple", |
||||
"world", |
"world", |
||||
"difference", |
|
||||
"celebration", |
|
||||
"association", |
|
||||
"customer", |
|
||||
|
"banana", |
||||
|
"cat", |
||||
|
"lemon", |
||||
|
"dog", |
||||
"mood", |
"mood", |
||||
"agreement", |
|
||||
"audience", |
|
||||
"professor", |
|
||||
|
"orange", |
||||
|
"kite", |
||||
|
"nest", |
||||
"year", |
"year", |
||||
"dealer", |
|
||||
"patience", |
|
||||
"table tennis", |
|
||||
"pollution", |
|
||||
"awareness", |
|
||||
|
"grape", |
||||
|
"sun", |
||||
|
"mouse", |
||||
|
"tennis", |
||||
|
"queen", |
||||
"problem", |
"problem", |
||||
"vehicle", |
"vehicle", |
||||
"death", |
"death", |
||||
"cousin" |
"cousin" |
||||
}; |
}; |
||||
|
|
||||
const char* selectRandomWord() { |
|
||||
|
// hard words |
||||
|
char wordsList_hard[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
||||
|
"database", |
||||
|
"programming", |
||||
|
"mountain", |
||||
|
"customer", |
||||
|
"table tennis", |
||||
|
"customer", |
||||
|
"laughter", |
||||
|
"expression", |
||||
|
"audience", |
||||
|
"professor", |
||||
|
"twilight", |
||||
|
"dealer", |
||||
|
"symphony", |
||||
|
"table tennis", |
||||
|
"pollution", |
||||
|
"inspiration", |
||||
|
"supermarket", |
||||
|
"difficulty", |
||||
|
"budget", |
||||
|
"quarter" |
||||
|
}; |
||||
|
|
||||
|
// super hard words |
||||
|
char wordsList_super_hard[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
||||
|
"Cacophony", |
||||
|
"Rambunctious", |
||||
|
"Serendipity", |
||||
|
"Resilience", |
||||
|
"Discombobulate", |
||||
|
"Pernicious", |
||||
|
"Eccentricity", |
||||
|
"Mellifluous", |
||||
|
"Ineffable", |
||||
|
"Obfuscate", |
||||
|
"Quixotic", |
||||
|
"Paradoxical", |
||||
|
"Esoteric", |
||||
|
"Perspicacious", |
||||
|
"Indubitable", |
||||
|
"Incandescent", |
||||
|
"Vicissitude", |
||||
|
"Juxtaposition", |
||||
|
"Exacerbate", |
||||
|
"Epiphany" |
||||
|
}; |
||||
|
|
||||
|
char* selectRandomWord(int difficulty) { |
||||
|
|
||||
// pick a random number and assign it to index of wordsList array |
|
||||
|
// pick a random number and assign it to index of wordsList_easy array |
||||
srand((unsigned int)time(NULL)); |
srand((unsigned int)time(NULL)); |
||||
int randomIndex = rand() % NUM_WORDS; |
int randomIndex = rand() % NUM_WORDS; |
||||
|
|
||||
return wordsList[randomIndex]; |
|
||||
|
switch(difficulty){ |
||||
|
case 1: |
||||
|
return wordsList_easy[randomIndex]; |
||||
|
case 2: |
||||
|
return wordsList_hard[randomIndex]; |
||||
|
case 3: |
||||
|
return wordsList_super_hard[randomIndex]; |
||||
|
default: |
||||
|
printf("Invalid difficulty level. We choose easy level for you.\n"); |
||||
|
return wordsList_easy[randomIndex]; |
||||
|
} |
||||
} |
} |
@ -0,0 +1,23 @@ |
|||||
|
#include <stdio.h> |
||||
|
#include "playHangman.h" |
||||
|
|
||||
|
|
||||
|
void test_displayRules() { |
||||
|
printf("Test Case 1: User inputs '1'\n"); |
||||
|
printf("Expected Output: 'Let's get started!'\n"); |
||||
|
printf("Actual Output: "); |
||||
|
printf("1\n"); |
||||
|
displayRules(); |
||||
|
|
||||
|
printf("\nTest Case 2: User inputs '2'\n"); |
||||
|
printf("Expected Output: Output of printRules() function\n"); |
||||
|
printf("Actual Output: "); |
||||
|
printf("2\n"); |
||||
|
displayRules(); |
||||
|
|
||||
|
printf("\nTest Case 3: User inputs invalid value\n"); |
||||
|
printf("Expected Output: 'Please enter either 1 or 2 to continue'\n"); |
||||
|
printf("Actual Output: "); |
||||
|
printf("invalid\n"); |
||||
|
displayRules(); |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue