From ba79098f577aeedb1f9dc1d6c5af296d6f423425 Mon Sep 17 00:00:00 2001 From: muktar1907 Date: Sat, 27 Apr 2024 02:03:45 -0500 Subject: [PATCH] fixed some testing errors --- src/main/java/uta/cse3310/GridField.java | 13 ++++++------- src/main/java/uta/cse3310/UserEvent.java | 5 +---- src/test/java/uta/cse3310/gameTest.java | 7 +++++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/uta/cse3310/GridField.java b/src/main/java/uta/cse3310/GridField.java index b0cc36f..b198dd8 100644 --- a/src/main/java/uta/cse3310/GridField.java +++ b/src/main/java/uta/cse3310/GridField.java @@ -5,19 +5,18 @@ public class GridField { private char[][] grid; - private ArrayList wordList; + private ArrayList wordList=new ArrayList(); private int remainingWords; public GridField(ArrayList wordList) { this.wordList = wordList; - this.remainingWords = wordList.size(); - generateGrid(5); // Initialize grid with default size (e.g., 5x5) + this.remainingWords=wordList.size(); + generateGrid(5); // Initialize grid with default size (e.g., 5x5) <-no need -muktar } public GridField() { this.wordList = WordList.getWordList("Data/words"); this.wordList = WordList.updatedWordList(wordList); - this.remainingWords = wordList.size(); - // Initialize grid with default size (e.g., 5x5) + } @@ -37,7 +36,7 @@ public void generateGrid(int gridSize) { grid[i][j] = (char) ('A' + random.nextInt(26)); // Randomly fill grid with alphabets } } - this.addWord("group",0,0,Direction.Directions.HORIZONTAL); + //this.addWord("group",0,0,Direction.Directions.HORIZONTAL); was testing selection function } public boolean checkWord(String word) { @@ -76,7 +75,7 @@ public void addWord(String word, int row, int column, Direction.Directions direc } wordList.add(word); //remainingWords starts off as the size of the updated wordlist - //remainingWords++; + remainingWords++; } public void displayGrid() { diff --git a/src/main/java/uta/cse3310/UserEvent.java b/src/main/java/uta/cse3310/UserEvent.java index ed4cdfc..2b62411 100644 --- a/src/main/java/uta/cse3310/UserEvent.java +++ b/src/main/java/uta/cse3310/UserEvent.java @@ -13,8 +13,5 @@ public class UserEvent { in order will create the selecting functionality */ - public String toString() - { - return "action: "+action; - } + } diff --git a/src/test/java/uta/cse3310/gameTest.java b/src/test/java/uta/cse3310/gameTest.java index 985a269..3807c8c 100644 --- a/src/test/java/uta/cse3310/gameTest.java +++ b/src/test/java/uta/cse3310/gameTest.java @@ -127,8 +127,7 @@ public void testUpdate() GridField gridField=new GridField(wordList); game.setGridField(gridField); game.startGame(); - game.setGridField(gridField); - game.startGame(); + char[][] grid =gridField.getGrid(); //test word String word=""; @@ -166,6 +165,10 @@ public void testUpdate() boolean var=game.updateGame(attempt); + for(int i=0;i