diff --git a/src/main/java/uta/cse3310/GridField.java b/src/main/java/uta/cse3310/GridField.java index 93de37b..c9462af 100644 --- a/src/main/java/uta/cse3310/GridField.java +++ b/src/main/java/uta/cse3310/GridField.java @@ -17,6 +17,8 @@ public GridField(ArrayList<String> wordList) { public GridField() { this.wordList = WordList.getWordList("Data/words"); this.wordList = WordList.updatedWordList(wordList); + this.remainingWords = wordList.size(); + generateGrid(5); // Initialize grid with default size (e.g., 5x5) } public char[][] getGrid() { @@ -103,7 +105,7 @@ private boolean canPlaceWord(String word, int row, int column, Direction.Directi int dr = direction.getRowIncrement(); int dc = direction.getColumnIncrement(); for (int i = 0; i < len; i++) { - if (row < 0 || row >= grid.length || column < 0 || column >= grid[0].length|| grid[row][column] != 0){ + if (row < 0 || row >= grid.length || column < 0 || column >= grid[0].length || grid[row][column] != 0) { return false; // Check if the word goes out of bounds or overlaps with existing letters } row += dr; @@ -111,4 +113,4 @@ private boolean canPlaceWord(String word, int row, int column, Direction.Directi } return true; } -} \ No newline at end of file +} diff --git a/src/test/java/uta/cse3310/GridFieldTest.java b/src/test/java/uta/cse3310/GridFieldTest.java index b573641..1811af7 100644 --- a/src/test/java/uta/cse3310/GridFieldTest.java +++ b/src/test/java/uta/cse3310/GridFieldTest.java @@ -51,7 +51,7 @@ public void testRevealWord() { public void testAddWord() { ArrayList<String> wordList = new ArrayList<>(); GridField gridField = new GridField(wordList); - gridField.addWord("HELLO", 0, 0, Direction.Directions.HORIZONTAL); // Adjusted here + gridField.addWord("HELLO", 0, 0, Direction.Directions.HORIZONTAL); assertEquals(1, gridField.getRemainingWords()); assertTrue(gridField.checkWord("HELLO")); } @@ -82,4 +82,4 @@ public void testPlaceRandomWords() { assertTrue(gridField.checkWord(word)); } } -} \ No newline at end of file +}