Skip to content

Commit

Permalink
fixed some testing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
muktar1907 committed Apr 27, 2024
1 parent bd45c42 commit ba79098
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
13 changes: 6 additions & 7 deletions src/main/java/uta/cse3310/GridField.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@

public class GridField {
private char[][] grid;
private ArrayList<String> wordList;
private ArrayList<String> wordList=new ArrayList<String>();
private int remainingWords;

public GridField(ArrayList<String> 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)

}


Expand All @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/uta/cse3310/UserEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ public class UserEvent {
in order will create the selecting functionality
*/
public String toString()
{
return "action: "+action;
}

}
7 changes: 5 additions & 2 deletions src/test/java/uta/cse3310/gameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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="";
Expand Down Expand Up @@ -166,6 +165,10 @@ public void testUpdate()


boolean var=game.updateGame(attempt);
for(int i=0;i<wordList.size();i++)
{
System.out.println(wordList.get(i));
}
assertTrue(wordList.size()==5);

}
Expand Down

0 comments on commit ba79098

Please sign in to comment.