diff --git a/CMakeLists.txt b/CMakeLists.txt index 763f8e7..455aa81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,14 +15,8 @@ add_executable(pmuw_projekt_notebinder src/main/c/main.h src/main/c/Hangman/drawHangman.c src/main/c/Hangman/drawHangman.h - src/main/c/Hangman/rules.c - src/main/c/Hangman/rules.h src/main/c/Hangman/initializeHangman.c src/main/c/Hangman/initializeHangman.h - src/main/c/Hangman/currentState.c - src/main/c/Hangman/currentState.h src/main/c/Hangman/playHangman.c src/main/c/Hangman/playHangman.h - src/main/c/Hangman/Test/test_drawHangman.c - src/main/c/Hangman/Test/test_drawHangman.h ) diff --git a/cmake-build-debug/.ninja_deps b/cmake-build-debug/.ninja_deps index df97cc5..3bcb602 100644 Binary files a/cmake-build-debug/.ninja_deps and b/cmake-build-debug/.ninja_deps differ diff --git a/cmake-build-debug/.ninja_log b/cmake-build-debug/.ninja_log index c60e4a8..4eb5881 100644 --- a/cmake-build-debug/.ninja_log +++ b/cmake-build-debug/.ninja_log @@ -1,13 +1,26 @@ # ninja log v5 -0 40 1706867178156302406 build.ninja f2183aada2fc9ffc -1 214 1706706276607374928 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o cdaff7b94c55641c -0 213 1706706276607336012 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o fab41de4b8cc0421 -1 214 1706706276607365429 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o 7d64de4520ec9e97 -1 43 1706797998872539655 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 -1 44 1706122039878920765 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Template/game100.c.o 69a5bcd8c57a43b3 -1 38 1706122217155672196 CMakeFiles/pmuw_projekt_notebinder.dir/test/Hangman/word_selector_test.c.o e932f546d59a9d76 -106 195 1706551302079685763 pmuw_projekt_notebinder fbb48fd3bf0b96c1 +0 32 1707224707015552741 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_playHangman.c.o c78eb198389ea64b +2 48 1707224297294010118 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_drawHangman.c.o b4d90a6b54ad1664 +1 40 1707224901227175471 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 1 38 1706122372717341436 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o f1dbf76e6b4bc97d -2 56 1706797998885305995 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 -1 115 1706866005935735539 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/currentState.c.o c4eef1ff589ab182 -1 114 1706866005935734705 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_drawHangman.c.o b4d90a6b54ad1664 +1 33 1707224901218890256 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/currentState.c.o c4eef1ff589ab182 +106 195 1706551302079685763 pmuw_projekt_notebinder fbb48fd3bf0b96c1 +1 38 1706122217155672196 CMakeFiles/pmuw_projekt_notebinder.dir/test/Hangman/word_selector_test.c.o e932f546d59a9d76 +1 44 1706122039878920765 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Template/game100.c.o 69a5bcd8c57a43b3 +1 38 1707224901221200228 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 +1 214 1706706276607365429 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o 7d64de4520ec9e97 +0 213 1706706276607336012 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o fab41de4b8cc0421 +2 47 1707224297291255019 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o cdaff7b94c55641c +0 42 1707224957969670299 build.ninja f2183aada2fc9ffc +0 34 1707224957969670299 build.ninja f2183aada2fc9ffc +1 29 1707224958003312078 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o 7d64de4520ec9e97 +1 34 1707224958007844146 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 +0 32 1707225145761047265 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 +1 31 1707225193573982892 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 +0 34 1707225362817701877 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 +0 45 1707225516452726019 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 +1 32 1707225552742056223 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 +32 62 1707225552772258606 pmuw_projekt_notebinder a5668107eb06d295 +0 32 1707225688396107422 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o f1dbf76e6b4bc97d +0 28 1707225694194160949 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o f1dbf76e6b4bc97d +28 61 1707225694227136765 pmuw_projekt_notebinder a5668107eb06d295 diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log index 5481496..bf59ee4 100644 --- a/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Feb 06 11:59 CET +Start testing: Feb 06 14:23 CET ---------------------------------------------------------- -End testing: Feb 06 11:59 CET +End testing: Feb 06 14:23 CET diff --git a/cmake-build-debug/build.ninja b/cmake-build-debug/build.ninja index 0264c76..be724d5 100644 --- a/cmake-build-debug/build.ninja +++ b/cmake-build-debug/build.ninja @@ -70,13 +70,6 @@ build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o: OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman -build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o: C_COMPILER__pmuw_projekt_notebinder_unscanned_Debug /Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman/rules.c || cmake_object_order_depends_target_pmuw_projekt_notebinder - DEP_FILE = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o.d - FLAGS = -g -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -fcolor-diagnostics - INCLUDES = -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Template - OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir - OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman - build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o: C_COMPILER__pmuw_projekt_notebinder_unscanned_Debug /Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman/initializeHangman.c || cmake_object_order_depends_target_pmuw_projekt_notebinder DEP_FILE = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o.d FLAGS = -g -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -fcolor-diagnostics @@ -84,13 +77,6 @@ build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangma OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman -build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/currentState.c.o: C_COMPILER__pmuw_projekt_notebinder_unscanned_Debug /Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman/currentState.c || cmake_object_order_depends_target_pmuw_projekt_notebinder - DEP_FILE = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/currentState.c.o.d - FLAGS = -g -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -fcolor-diagnostics - INCLUDES = -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Template - OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir - OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman - build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o: C_COMPILER__pmuw_projekt_notebinder_unscanned_Debug /Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman/playHangman.c || cmake_object_order_depends_target_pmuw_projekt_notebinder DEP_FILE = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o.d FLAGS = -g -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -fcolor-diagnostics @@ -98,20 +84,6 @@ build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o: OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman -build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_drawHangman.c.o: C_COMPILER__pmuw_projekt_notebinder_unscanned_Debug /Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman/Test/test_drawHangman.c || cmake_object_order_depends_target_pmuw_projekt_notebinder - DEP_FILE = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_drawHangman.c.o.d - FLAGS = -g -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -fcolor-diagnostics - INCLUDES = -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Template - OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir - OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test - -build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_currentState.c.o: C_COMPILER__pmuw_projekt_notebinder_unscanned_Debug /Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman/Test/test_currentState.c || cmake_object_order_depends_target_pmuw_projekt_notebinder - DEP_FILE = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_currentState.c.o.d - FLAGS = -g -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -fcolor-diagnostics - INCLUDES = -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Hangman -I/Users/saba/CLionProjects/pmuw_projekt_notebinder/src/main/c/Template - OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir - OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test - # ============================================================================= # Link build statements for EXECUTABLE target pmuw_projekt_notebinder @@ -120,7 +92,7 @@ build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_curren ############################################# # Link the executable pmuw_projekt_notebinder -build pmuw_projekt_notebinder: C_EXECUTABLE_LINKER__pmuw_projekt_notebinder_Debug CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/currentState.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_drawHangman.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/Test/test_currentState.c.o +build pmuw_projekt_notebinder: C_EXECUTABLE_LINKER__pmuw_projekt_notebinder_Debug CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o FLAGS = -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir POST_BUILD = : diff --git a/src/main/c/Hangman/Test/test_playHangman.c b/src/main/c/Hangman/Test/test_playHangman.c new file mode 100644 index 0000000..482eb2c --- /dev/null +++ b/src/main/c/Hangman/Test/test_playHangman.c @@ -0,0 +1,19 @@ +#include "playHangman.c" +#include +#include + + +// Custom assert function to compare expected and actual values +void assert_equal(const char *test_name, const char *expected, const char *actual) { + if (strcmp(expected, actual) == 0) { + printf("[PASS] %s\n", test_name); + } else { + printf("[FAIL] %s - Expected: \"%s\", Actual: \"%s\"\n", test_name, expected, actual); + } +} + +// Test function for playHangman() +void test_playHangman() { + char wordToGuess[] = "test"; + //playHangman(wordToGuess); +} \ No newline at end of file diff --git a/src/main/c/Hangman/currentState.c b/src/main/c/Hangman/currentState.c deleted file mode 100644 index e4bc459..0000000 --- a/src/main/c/Hangman/currentState.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "currentState.h" - -void currentState(char *currentGuess, int mistakes) { - printf("Current Word: %s \n", currentGuess); - printf("Mistakes Made: %d/6 \n", mistakes); - drawHangman(mistakes); -} \ No newline at end of file diff --git a/src/main/c/Hangman/currentState.h b/src/main/c/Hangman/currentState.h deleted file mode 100644 index dbf10bf..0000000 --- a/src/main/c/Hangman/currentState.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef PMUW_PROJEKT_NOTEBINDER_CURRENTSTATE_H -#define PMUW_PROJEKT_NOTEBINDER_CURRENTSTATE_H -#include -#include "drawHangman.c" -#endif //PMUW_PROJEKT_NOTEBINDER_CURRENTSTATE_H diff --git a/src/main/c/Hangman/drawHangman.c b/src/main/c/Hangman/drawHangman.c index 483e4ec..12b074a 100644 --- a/src/main/c/Hangman/drawHangman.c +++ b/src/main/c/Hangman/drawHangman.c @@ -83,4 +83,10 @@ void drawHangman(int incorrectGuesses) { " \n" " \n"); } +} + +void currentState(char *currentGuess, int mistakes) { + printf("Current Word: %s \n", currentGuess); + printf("Mistakes Made: %d/6 \n", mistakes); + drawHangman(mistakes); } \ No newline at end of file diff --git a/src/main/c/Hangman/initializeHangman.c b/src/main/c/Hangman/initializeHangman.c index 221e50e..9ea56a2 100644 --- a/src/main/c/Hangman/initializeHangman.c +++ b/src/main/c/Hangman/initializeHangman.c @@ -10,4 +10,9 @@ void initializeHangman(char *wordToGuess, char *currentGuess) { } } currentGuess[wordLength] = '\0'; +} + +void printRules(){ + printf("Rules: \n"); + printf(" - You are allowed a maximum of 6 mistakes.\n"); } \ No newline at end of file diff --git a/src/main/c/Hangman/playHangman.h b/src/main/c/Hangman/playHangman.h index ca1348e..aad634c 100644 --- a/src/main/c/Hangman/playHangman.h +++ b/src/main/c/Hangman/playHangman.h @@ -1,10 +1,21 @@ #ifndef PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H #define PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H + #include + +// Include declarations from corresponding header files +#include "initializeHangman.h" +#include "drawHangman.h" +#include "word_selector.h" + +// Include function implementations directly from .c files +void initializeHangman(char *wordToGuess, char *currentGuess); +void printRules(); +void drawHangman(int incorrectGuesses); +void currentState(char *currentGuess, int mistakes); +const char* selectRandomWord(); +const char wordsList[NUM_WORDS][MAX_WORD_LENGTH + 1]; + #define MAX_MISTAKES 6 -#include "initializeHangman.c" -#include "rules.c" -#include "currentState.c" -#include "drawHangman.c" -#include "word_selector.c" -#endif //PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H \ No newline at end of file + +#endif // PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H diff --git a/src/main/c/Hangman/rules.c b/src/main/c/Hangman/rules.c deleted file mode 100644 index f7802bb..0000000 --- a/src/main/c/Hangman/rules.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "rules.h" - -void printRules(){ - printf("Rules: \n"); - printf(" - You are allowed a maximum of 6 mistakes.\n"); - printf(" - All alphabet are in lower case.\n"); -} \ No newline at end of file diff --git a/src/main/c/Hangman/rules.h b/src/main/c/Hangman/rules.h deleted file mode 100644 index 35b01a1..0000000 --- a/src/main/c/Hangman/rules.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef PMUW_PROJEKT_NOTEBINDER_RULES_H -#define PMUW_PROJEKT_NOTEBINDER_RULES_H -#include -#endif //PMUW_PROJEKT_NOTEBINDER_RULES_H diff --git a/src/main/c/main.c b/src/main/c/main.c index 90f28f1..2a8a9b3 100644 --- a/src/main/c/main.c +++ b/src/main/c/main.c @@ -2,7 +2,10 @@ #include #include -//#include "Template/game100.h" +#include "Hangman/playHangman.h" +#include "Hangman/word_selector.h" +#include "Hangman/drawHangman.h" +#include "Hangman/initializeHangman.h" int main(){ bool running = true; diff --git a/src/main/c/main.h b/src/main/c/main.h index 899f8f6..71870e0 100644 --- a/src/main/c/main.h +++ b/src/main/c/main.h @@ -1,7 +1,6 @@ #ifndef MAIN_H #define MAIN_H -#include "playHangman.h" -#include "playHangman.c" + int main(); #endif // MAIN_H \ No newline at end of file