Compare commits
3 Commits
4041e9ee9b
...
c95c264a3a
| Author | SHA1 | Date | |
|---|---|---|---|
| c95c264a3a | |||
|
|
147fc502eb | ||
| 27eafd14cc |
@ -37,17 +37,21 @@ int main(int argc, char *argv[])
|
|||||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||||
|
|
||||||
// Check if all words were successfully placed
|
// Check if all words were successfully placed
|
||||||
// Start the game if successful
|
|
||||||
// error message if some words couldn't be placed
|
// error message if some words couldn't be placed
|
||||||
|
|
||||||
if (placedWords < wordCount)
|
if (placedWords < wordCount)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "some words couldn't be placed\n");
|
int notPlacedNum = wordCount - placedWords;
|
||||||
exitCode = EXIT_FAILURE;
|
fprintf(stderr, "%d word(s) couldn't be placed\n", notPlacedNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// Start the game if successful
|
// correct parameters for startGame
|
||||||
|
|
||||||
|
// Start the game if at least 1 word has been successfully placed
|
||||||
|
else if (placedWords >= 1)
|
||||||
|
{
|
||||||
|
startGame(wordSalad, 80, words, placedWords, 800);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -16,9 +16,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
// set seed for random number generator
|
// set seed for random number generator
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
int r, c;
|
int r, c, placedWords=0;
|
||||||
|
|
||||||
//Gesamtes Feld auf 0 setzen
|
//Gesamtes Feld auf 0 setzen, am besten in eigene Fkt, dann aber extra Tests dafür erstellen
|
||||||
for (r=0; r < searchFieldLen; r++) {
|
for (r=0; r < searchFieldLen; r++) {
|
||||||
for (c=0; c < searchFieldLen; c++) {
|
for (c=0; c < searchFieldLen; c++) {
|
||||||
salad [r][c] = EMPTY_CHAR;
|
salad [r][c] = EMPTY_CHAR;
|
||||||
@ -33,7 +33,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
//Prüfen, ob das Wort von der Länge her ins Feld passt
|
//Prüfen, ob das Wort von der Länge her ins Feld passt
|
||||||
|
|
||||||
|
|
||||||
//Felder, in denen keine Wörter stehen, werden mit zufälligen Buchstaben befüllt
|
//Felder, in denen keine Wörter stehen, werden mit zufälligen Buchstaben befüllt, am besten in eigene Fkt, dann aber extra Tests dafür erstellen
|
||||||
for (r=0; r < searchFieldLen; r++) {
|
for (r=0; r < searchFieldLen; r++) {
|
||||||
for (c=0; c < searchFieldLen; c++) {
|
for (c=0; c < searchFieldLen; c++) {
|
||||||
if (salad[r][c] == EMPTY_CHAR) {
|
if (salad[r][c] == EMPTY_CHAR) {
|
||||||
@ -41,8 +41,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//return "Anzahl platzierter Wörter", wird in Main dann mit soll verglichen
|
||||||
return 0;
|
return placedWords;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints the word salad to console
|
// Prints the word salad to console
|
||||||
|
|||||||
@ -37,17 +37,21 @@ int main(int argc, char *argv[])
|
|||||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||||
|
|
||||||
// Check if all words were successfully placed
|
// Check if all words were successfully placed
|
||||||
// Start the game if successful
|
|
||||||
// error message if some words couldn't be placed
|
// error message if some words couldn't be placed
|
||||||
|
|
||||||
if (placedWords < wordCount)
|
if (placedWords < wordCount)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "some words couldn't be placed\n");
|
int notPlacedNum = wordCount - placedWords;
|
||||||
exitCode = EXIT_FAILURE;
|
fprintf(stderr, "%d word(s) couldn't be placed\n", notPlacedNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// Start the game if successful
|
// correct parameters for startGame
|
||||||
|
|
||||||
|
// Start the game if at least 1 word has been successfully placed
|
||||||
|
else if (placedWords >= 1)
|
||||||
|
{
|
||||||
|
startGame(wordSalad, 80, words, placedWords, 800);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user