Browse Source

Added One Player Only Checker + Test

dev
Adem Berber 3 years ago
parent
commit
c145c2b510
  1. 29
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 7
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

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

@ -1281,4 +1281,33 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkOnePlayerOnly() {
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")) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
}

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

@ -219,4 +219,11 @@ public class GamesTest extends TestCase {
String actual = testObject.checkEightPlayer();
assertEquals(expected, actual);
}
public void test_checkOnePlayerOnly() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Ratchet & Clank, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Yakuza: Dead Souls, Breakdown, AI: The Somnium Files, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkOnePlayerOnly();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save