diff --git a/Start_Windows/game.c b/Start_Windows/game.c index 941292f..7908fe4 100644 --- a/Start_Windows/game.c +++ b/Start_Windows/game.c @@ -15,14 +15,14 @@ // Creates the word salad by placing words randomly and filling empty spaces int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount) { int addedWords = 0; - int attempts = 0; - int added = 0; - int space = 1; + int attempts = 0; //Anzahl an Versuchen ein Wort hinzuzufügen + int added = 0; //0 Wort nicht hinzugefügt , 1 Wort hinzugefügt + int space = 1; // 0 Wort zu lang, 1 Wort passt an diese Stelle unsigned long long wordLength = 0; for (int i = 0; i < searchFieldLen; i++) { for (int j = 0; j < searchFieldLen; j++) { - salad[i][j] = EMPTY_CHAR; + salad[i][j] = EMPTY_CHAR; //Füllen des gesamten Arrays mit Nullen } } for (int i=0; i < wordCount; i++) { @@ -30,25 +30,27 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi wordLength = strlen(words[i]); while (attempts <= MAX_RAND_TRIES_PER_WORD && added != 1) { - int direction = rand() % 2; + int direction = rand() % 2;// 0 Horizontal, 1 Vertikal if (direction == 0) { int collumn = rand() % searchFieldLen; int row = rand() % searchFieldLen; for (int j = 0; j < wordLength; j++) { if (salad[row][collumn+j] != EMPTY_CHAR) {space = 0; break;} + //Prüfen ob das Wort ein bereits vorhandenes Wort überspeichern würde } if ((collumn + wordLength >= searchFieldLen-1) || (space == 0)) {attempts++;} + //Prüfen ob Wort an der Stelle (Zeile, Spalte) in das Array passt else {for (int j = 0; j < wordLength; j++) { - salad[row][collumn+j] = words[i][j]; + salad[row][collumn+j] = words[i][j]; //Einfügen des Wortes Buchstabe für Buchstabe } added=1; addedWords++; } } - else if (direction == 1) { + else if (direction == 1) {// Vertikal funktioniert analog zu horizontal int collumn = rand() % searchFieldLen; int row = rand() % searchFieldLen; for (int j = 0; j < wordLength; j++) @@ -75,7 +77,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi for (int j = 0; j < searchFieldLen; j++) { if (salad[i][j] == EMPTY_CHAR) { - salad[i][j] = rand()%('Z'-'A'+1)+'A'; + salad[i][j] = rand()%('Z'-'A'+1)+'A';//Alle Felder, die noch nicht befüllt sind, werden zufällig befüllt + } } @@ -90,7 +93,7 @@ void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], { for(int j = 0; j < searchFieldLen; j++) { - printf("%c", salad[i][j]); + printf("%c", salad[i][j]);//Ausgabe des Arrays auf die Konsole } } } diff --git a/Start_Windows/game.o b/Start_Windows/game.o deleted file mode 100644 index 9f84c3f..0000000 Binary files a/Start_Windows/game.o and /dev/null differ diff --git a/Start_Windows/graphicalGame.o b/Start_Windows/graphicalGame.o deleted file mode 100644 index 35dff31..0000000 Binary files a/Start_Windows/graphicalGame.o and /dev/null differ diff --git a/Start_Windows/input.c b/Start_Windows/input.c index cdb5ece..025ba18 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -9,27 +9,27 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { char zeile[MAX_LINE_LEN]; - char* teiler = ".;, "; + char* teiler = ".;, "; //Trennung zwischen den Wörtern einer Zeile int wordCount = 0; - char* token; - while(fgets(zeile, MAX_LINE_LEN, file)!=NULL) + char* token; // Einzelwort aus Zeile + while(fgets(zeile, MAX_LINE_LEN, file)!=NULL) //Zeilenweises einlesen { for (int i = 0; i < MAX_LINE_LEN; i++) { - if (zeile[i] >= 'a'&&zeile[i] <= 'z') + if (zeile[i] >= 'a'&&zeile[i] <= 'z') //Ersetzen aller Kleinbuchstaben in Großbuchstaben { - zeile[i]=zeile[i]-32; + zeile[i]=zeile[i]-32; //ASCII-Code -32 entspricht dem jeweiligen Großbuchstaben } if (zeile[i] == '\n') { - zeile[i] = '\0'; + zeile[i] = '\0'; //Ende der Zeile = String Ende break; } } token = strtok(zeile,teiler); - while(token != NULL && wordCount <= maxWordCount) + while(token != NULL && wordCount < maxWordCount) { - strcpy(words[wordCount],token); + strcpy(words[wordCount],token);//Trennen der Wörter in einer Zeile und kopieren in 2D Array "untereinander" token = strtok(NULL,teiler); wordCount++; } diff --git a/Start_Windows/input.o b/Start_Windows/input.o deleted file mode 100644 index bd8f22f..0000000 Binary files a/Start_Windows/input.o and /dev/null differ diff --git a/Start_Windows/main.o b/Start_Windows/main.o deleted file mode 100644 index b71a673..0000000 Binary files a/Start_Windows/main.o and /dev/null differ diff --git a/Start_Windows/runTests.exe b/Start_Windows/runTests.exe deleted file mode 100644 index 2489cfa..0000000 Binary files a/Start_Windows/runTests.exe and /dev/null differ diff --git a/Start_Windows/wordsalad.exe b/Start_Windows/wordsalad.exe deleted file mode 100644 index e502980..0000000 Binary files a/Start_Windows/wordsalad.exe and /dev/null differ diff --git a/Start_Windows/wordsalad_initial.exe b/Start_Windows/wordsalad_initial.exe deleted file mode 100644 index 29d6ed3..0000000 Binary files a/Start_Windows/wordsalad_initial.exe and /dev/null differ diff --git a/Test.txt b/Test.txt deleted file mode 100644 index 9de4eb2..0000000 --- a/Test.txt +++ /dev/null @@ -1,5 +0,0 @@ -Hello world - -Polizfi - -Hallo \ No newline at end of file diff --git a/ersz004z80vDesktopc projectsI2 PraktikumAufgabe1-Info2P b/ersz004z80vDesktopc projectsI2 PraktikumAufgabe1-Info2P deleted file mode 100644 index 0e33521..0000000 --- a/ersz004z80vDesktopc projectsI2 PraktikumAufgabe1-Info2P +++ /dev/null @@ -1,29 +0,0 @@ -commit e58f113c46c1af49c3680b6da5cc999b56b0093a (HEAD -> main, origin/main, origin/HEAD) -Author: Kruschat -Date: Thu Oct 23 14:55:49 2025 +0200 - - Test geändert - -commit 89ca3acc38758a65a28a874ceda5d3253c1cb6d8 -Author: Bannach -Date: Thu Oct 23 14:54:03 2025 +0200 - - Testdatei - -commit 15db90e12e6413714750ac23a78aa369bf192a22 -Author: Bannach -Date: Thu Oct 23 14:52:08 2025 +0200 - - Testdatei aktualisiert - -commit b804c4264c21980ba6497fb76da0da6151c1b9ed -Author: Bannach -Date: Wed Oct 22 20:57:00 2025 +0200 - - Textdatei Test hinzugefügt - -commit 496e4d82e75945b8899aa012e0039034f40a1db1 -Author: Kevin Bannach -Date: Wed Oct 22 07:21:52 2025 +0000 - - Initial commit