Skip to content

Commit

Permalink
Merge pull request #54 from utastudents/w_lobby
Browse files Browse the repository at this point in the history
added more test cases
  • Loading branch information
wdn5349 authored May 1, 2024
2 parents c9153e6 + 7be665e commit 445ee68
Show file tree
Hide file tree
Showing 31 changed files with 56 additions and 243 deletions.
17 changes: 11 additions & 6 deletions src/main/java/com/cse3310/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class Game {
public ArrayList<Integer> ActiveButtons;
public ArrayList<Integer> CompletedButtons;
public ArrayList<Integer> AllCompletedButtons;
public double gridDensity;
public double gridTime;


public Game() {
this.wordBank = new ArrayList<String>();
Expand Down Expand Up @@ -204,12 +207,13 @@ public char[][] generateGrid(ArrayList<String> words, ArrayList<String> wordbank

}

System.out.println("Actual Density: " + (double) validWordsLetters / (length * width));
System.out.println("Upward Diagonals: " + (diagUp / index));
System.out.println("Downward Diagonals: " + (diagDown / index));
System.out.println("Horizontals: " + (horizontals / index));
System.out.println("Downward verticals: " + (vertDown / index));
System.out.println("Upward verticals:" + (vertUp / index));
System.out.println("Actual Density: " + (double)validWordsLetters / (length * width));
this.gridDensity = (double)validWordsLetters / (length * width);
System.out.println("Upward Diagonals: " + (diagUp/index));
System.out.println("Downward Diagonals: " + (diagDown/index));
System.out.println("Horizontals: " + (horizontals/index));
System.out.println("Downward verticals: " + (vertDown/index));
System.out.println("Upward verticals:" + (vertUp/index));

// Fill in rest of the grid with random letters
// Print grid to console for debugging
Expand All @@ -227,6 +231,7 @@ public char[][] generateGrid(ArrayList<String> words, ArrayList<String> wordbank
}
double endTime = System.currentTimeMillis();
System.out.println("Time to generate grid: " + (endTime - startTime) + " ms");
this.gridTime = endTime - startTime;
System.out.println("Word Bank: " + wordBank);
System.out.println();

Expand Down
45 changes: 45 additions & 0 deletions src/test/java/com/cse3310/GameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

import static org.junit.Assert.assertArrayEquals;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;

Expand Down Expand Up @@ -102,4 +105,46 @@ public void testGenerateGrid() {
GenerateGrid(B);
}


public void densityIsWithinRange(){

String filename = "words.txt";
ArrayList<String> wordList = new ArrayList<>();

try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
String line;
while ((line = br.readLine()) != null) {
wordList.add(line.trim());
}
} catch (IOException e) {
System.err.println("Error reading file:" + e.getMessage());
}

Game g = new Game(wordList, 0);

System.out.println("DENSITY IS " + g.gridDensity);
assertTrue(g.gridDensity >= 0.67);
}


public void timeIsWithinRange(){

String filename = "words.txt";
ArrayList<String> wordList = new ArrayList<>();

try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
String line;
while ((line = br.readLine()) != null) {
wordList.add(line.trim());
}
} catch (IOException e) {
System.err.println("Error reading file:" + e.getMessage());
}

Game g = new Game(wordList, 0);

System.out.println("TIME IS " + g.gridTime);
assertTrue(g.gridTime <= 1000);
}

}
Binary file removed target/classes/com/cse3310/App$LetterTimer.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/App.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/Error.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/Game.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/HttpServer$1.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/HttpServer.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/Lobby.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/PlayerList.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/ServerEvent.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/User.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/UserEvent.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/Version.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/Winner.class
Binary file not shown.
Binary file removed target/classes/com/cse3310/timerEvent.class
Binary file not shown.
Binary file removed target/cse3310-wordsearch.jar
Binary file not shown.
4 changes: 0 additions & 4 deletions target/maven-archiver/pom.properties

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

62 changes: 0 additions & 62 deletions target/surefire-reports/TEST-com.cse3310.AppTest.xml

This file was deleted.

65 changes: 0 additions & 65 deletions target/surefire-reports/TEST-com.cse3310.GameTest.xml

This file was deleted.

Loading

0 comments on commit 445ee68

Please sign in to comment.