Browse Source

Added more Player Checkers + Tests

dev
Adem Berber 3 years ago
parent
commit
7996b7c8c2
  1. 58
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 14
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

58
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java

@ -1223,4 +1223,62 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkFourPlayer() {
String result = "";
String query = "SELECT Game_Name, Game_Players FROM Games";
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gamePlayers = resultSet.getString("Game_Players");
if (gamePlayers.equals("1-4") || gamePlayers.equals("1-8")) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkEightPlayer() {
String result = "";
String query = "SELECT Game_Name, Game_Players FROM Games";
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gamePlayers = resultSet.getString("Game_Players");
if (gamePlayers.equals("1-8")) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
}

14
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

@ -205,4 +205,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkTwoPlayer();
assertEquals(expected, actual);
}
public void test_checkFourPlayer() {
Games testObject = new Games();
String expected = "Super Smash Bros. Ultimate, Jet Set Radio Future";
String actual = testObject.checkFourPlayer();
assertEquals(expected, actual);
}
public void test_checkEightPlayer() {
Games testObject = new Games();
String expected = "Super Smash Bros. Ultimate";
String actual = testObject.checkEightPlayer();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save