Browse Source

Added Player Checkers + Tests

dev
Adem Berber 3 years ago
parent
commit
89e5697114
  1. BIN
      projjpn/GamesDB.laccdb
  2. 58
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  3. 14
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

BIN
projjpn/GamesDB.laccdb

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

@ -1165,4 +1165,62 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkOnePlayer() {
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") || gamePlayers.equals("1-2") || 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 checkTwoPlayer() {
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-2") || 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);
}
} }

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

@ -191,4 +191,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkAllDifferentReleaseYear(); String actual = testObject.checkAllDifferentReleaseYear();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkOnePlayer() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Yakuza: Dead Souls, Jet Set Radio Future, Breakdown, AI: The Somnium Files, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkOnePlayer();
assertEquals(expected, actual);
}
public void test_checkTwoPlayer() {
Games testObject = new Games();
String expected = "Astral Chain, Super Smash Bros. Ultimate, Jet Set Radio Future";
String actual = testObject.checkTwoPlayer();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save