Browse Source

Added additional PEGI Checkers + Tests

dev
Adem Berber 3 years ago
parent
commit
266f737625
  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

@ -1527,4 +1527,62 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkPegiTwelve() {
String result = "";
String query = "SELECT Game_Name, Game_PEGI_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");
int gamePegi = resultSet.getInt("Game_PEGI_Rating");
if (gamePegi == 12) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkPegiSixteen() {
String result = "";
String query = "SELECT Game_Name, Game_PEGI_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");
int gamePegi = resultSet.getInt("Game_PEGI_Rating");
if (gamePegi == 16) {
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

@ -275,5 +275,19 @@ public class GamesTest extends TestCase {
String actual = testObject.checkPegiSeven();
assertEquals(expected, actual);
}
public void test_checkPegiTwelve() {
Games testObject = new Games();
String expected = "Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkPegiTwelve();
assertEquals(expected, actual);
}
public void test_checkPegiSixteen() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Astral Chain";
String actual = testObject.checkPegiSixteen();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save