Browse Source

Added ESRB Checkers + Tests

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

BIN
projjpn/GamesDB.accdb

BIN
projjpn/GamesDB.laccdb

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

@ -1643,4 +1643,62 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkEsrbE() {
String result = "";
String query = "SELECT Game_Name, Game_ESRB_Rating 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 gameEsrb = resultSet.getString("Game_ESRB_Rating");
if (gameEsrb.equals("E")) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkEsrbEten() {
String result = "";
String query = "SELECT Game_Name, Game_ESRB_Rating 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 gameEsrb = resultSet.getString("Game_ESRB_Rating");
if (gameEsrb.equals("E10+")) {
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

@ -303,4 +303,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkPegiUnknown();
assertEquals(expected, actual);
}
public void test_checkEsrbE() {
Games testObject = new Games();
String expected = "Rhythm Paradise, Tomodachi Life, Beautiful Katamari";
String actual = testObject.checkEsrbE();
assertEquals(expected, actual);
}
public void test_checkEsrbEten() {
Games testObject = new Games();
String expected = "Super Smash Bros. Ultimate, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkEsrbEten();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save