Browse Source

Added More ESRB Checkers + Tests

dev
Adem Berber 2 years ago
parent
commit
6573b241f4
  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

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

@ -317,4 +317,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkEsrbEten();
assertEquals(expected, actual);
}
public void test_checkEsrbT() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Jet Set Radio Future, Atelier Totori Plus";
String actual = testObject.checkEsrbT();
assertEquals(expected, actual);
}
public void test_checkEsrbM() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Breakdown, AI: The Somnium Files, Persona 3 Portable";
String actual = testObject.checkEsrbM();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save