From 46ad0afc6022dd33c1c1be77880af5c98caa289e Mon Sep 17 00:00:00 2001 From: 2onefan2 <159247397+2onefan2@users.noreply.github.com> Date: Sun, 28 Apr 2024 23:54:21 -0500 Subject: [PATCH] Updated --- src/main/java/uta/cse3310/GridField.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/uta/cse3310/GridField.java b/src/main/java/uta/cse3310/GridField.java index da6aae0..623fa7f 100644 --- a/src/main/java/uta/cse3310/GridField.java +++ b/src/main/java/uta/cse3310/GridField.java @@ -11,13 +11,12 @@ public class GridField { public GridField(ArrayList wordList) { this.wordList = wordList; this.remainingWords = wordList.size(); - generateGrid(5); // Initialize grid with default size (e.g., 5x5) and place random words + generateGrid(5); // Initialize grid with default size (e.g., 5x5) } public GridField() { this.wordList = WordList.getWordList("Data/words"); this.wordList = WordList.updatedWordList(wordList); - generateGrid(5); // Initialize grid with default size (e.g., 5x5) and place random words } public char[][] getGrid() { @@ -36,9 +35,6 @@ public void generateGrid(int gridSize) { grid[i][j] = (char) ('A' + random.nextInt(26)); // Randomly fill grid with alphabets } } - - // Place random words on the grid - placeRandomWords(); } public boolean checkWord(String word) { @@ -50,7 +46,8 @@ public int getRemainingWords() { } public void revealWord(String word) { - if (wordList.remove(word)) { + if (wordList.contains(word)) { + wordList.remove(word); remainingWords--; } }