Browse Source

hang man main body (basics)

remotes/origin/Saba
Saba Fazlali 11 months ago
parent
commit
81858366e7
  1. 2
      CMakeLists.txt
  2. 4
      cmake-build-debug/.ninja_log
  3. 4
      cmake-build-debug/Testing/Temporary/LastTest.log
  4. 16
      cmake-build-debug/build.ninja
  5. 33
      src/main/c/Hangman/playHangman.c
  6. 12
      src/main/c/Hangman/playHangman.h

2
CMakeLists.txt

@ -21,4 +21,6 @@ add_executable(pmuw_projekt_notebinder
src/main/c/Hangman/initializeHangman.h src/main/c/Hangman/initializeHangman.h
src/main/c/Hangman/currentState.c src/main/c/Hangman/currentState.c
src/main/c/Hangman/currentState.h src/main/c/Hangman/currentState.h
src/main/c/Hangman/playHangman.c
src/main/c/Hangman/playHangman.h
) )

4
cmake-build-debug/.ninja_log

@ -1,9 +1,9 @@
# ninja log v5 # ninja log v5
1 38 1706122217155672196 CMakeFiles/pmuw_projekt_notebinder.dir/test/Hangman/word_selector_test.c.o e932f546d59a9d76 1 38 1706122217155672196 CMakeFiles/pmuw_projekt_notebinder.dir/test/Hangman/word_selector_test.c.o e932f546d59a9d76
0 40 1706703246979925624 build.ninja f2183aada2fc9ffc
0 40 1706703919580754893 build.ninja f2183aada2fc9ffc
1 38 1706122372717341436 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o f1dbf76e6b4bc97d 1 38 1706122372717341436 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/main.c.o f1dbf76e6b4bc97d
1 145 1706549408123039155 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o fab41de4b8cc0421
0 106 1706551301992128657 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o cdaff7b94c55641c 0 106 1706551301992128657 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o cdaff7b94c55641c
1 145 1706549408123039155 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o fab41de4b8cc0421
0 106 1706551301992114407 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 0 106 1706551301992114407 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 44 1706122039878920765 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Template/game100.c.o 69a5bcd8c57a43b3
106 195 1706551302079685763 pmuw_projekt_notebinder fbb48fd3bf0b96c1 106 195 1706551302079685763 pmuw_projekt_notebinder fbb48fd3bf0b96c1

4
cmake-build-debug/Testing/Temporary/LastTest.log

@ -1,3 +1,3 @@
Start testing: Jan 31 13:14 CET
Start testing: Jan 31 13:25 CET
---------------------------------------------------------- ----------------------------------------------------------
End testing: Jan 31 13:14 CET
End testing: Jan 31 13:25 CET

16
cmake-build-debug/build.ninja

@ -84,6 +84,20 @@ build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangma
OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir
OBJECT_FILE_DIR = CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman 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
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
# ============================================================================= # =============================================================================
# Link build statements for EXECUTABLE target pmuw_projekt_notebinder # Link build statements for EXECUTABLE target pmuw_projekt_notebinder
@ -92,7 +106,7 @@ build CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangma
############################################# #############################################
# Link the executable pmuw_projekt_notebinder # 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
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
FLAGS = -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk FLAGS = -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk
OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir OBJECT_DIR = CMakeFiles/pmuw_projekt_notebinder.dir
POST_BUILD = : POST_BUILD = :

33
src/main/c/Hangman/playHangman.c

@ -0,0 +1,33 @@
#include "playHangman.h"
void playHangman(char *wordToGuess) {
int mistakes = 0;
char guessedLetters[30]; //guessed letters
char currentGuess[50]; //current state of the guessed word
// Initialize the current guess and print the rules
initializeHangman(wordToGuess, currentGuess);
printRules();
while (mistakes < MAX_MISTAKES) {
currentState(currentGuess, mistakes);
// Get a letter from the player
char guess;
printf("\n\t Enter your guess (lower case): ");
scanf(" %c", &guess);
// Add the guessed letter to the list
guessedLetters[strlen(guessedLetters)] = guess;
// Check if the guessed letter is in the word
int found = 0;
for (int i = 0; i < strlen(wordToGuess); ++i) {
if (wordToGuess[i] == guess) {
currentGuess[i] = guess;
found = 1;
}
}
}
}

12
src/main/c/Hangman/playHangman.h

@ -0,0 +1,12 @@
//
// Created by Saba Fazlali on 31.01.24.
//
#ifndef PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H
#define PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H
#include <stdio.h>
#define MAX_MISTAKES 6
#include "initializeHangman.c"
#include "rules.c"
#include "currentState.c"
#endif //PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H
Loading…
Cancel
Save