Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
2onefan2 committed Apr 29, 2024
1 parent eb8ef37 commit d822692
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main/java/uta/cse3310/GridField.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package uta.cse3310;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

public class GridField {
Expand All @@ -15,8 +16,7 @@ public GridField(ArrayList<String> wordList) {
}

public GridField() {
this.wordList = WordList.getWordList("Data/words");
this.wordList = WordList.updatedWordList(wordList);
this(WordList.getWordList("Data/words")); // Using WordList class to fetch word list
}

public char[][] getGrid() {
Expand Down Expand Up @@ -64,15 +64,6 @@ public void addWord(String word, int row, int column, Direction.Directions direc
remainingWords++;
}

public void displayGrid() {
for (char[] row : grid) {
for (char cell : row) {
System.out.print(cell + " ");
}
System.out.println();
}
}

public void placeRandomWords() {
Random random = new Random();
ArrayList<String> remainingWords = new ArrayList<>(wordList); // Create a copy of the wordList to track remaining words
Expand All @@ -94,7 +85,7 @@ public void placeRandomWords() {
if (wordPlaced) {
remainingWords.remove(word); // Remove the word from remainingWords if successfully placed
} else {
System.out.println("Failed to place word: " + word); // Print a message if the word cannot be placed
System.out.println("Failed to place word: " + word);
}
}
}
Expand All @@ -112,4 +103,13 @@ private boolean canPlaceWord(String word, int row, int column, Direction.Directi
}
return true;
}

public void displayGrid() {
for (char[] row : grid) {
for (char cell : row) {
System.out.print(cell + " ");
}
System.out.println();
}
}
}

0 comments on commit d822692

Please sign in to comment.