diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java index 9b602f9..3f5ab62 100644 --- a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java +++ b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java @@ -1469,4 +1469,62 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkPegiThree() { + 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 == 3) { + result += gameName + ", "; + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } + + public String checkPegiSeven() { + 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 == 7) { + result += gameName + ", "; + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } } diff --git a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java index c5997fb..887c8b1 100644 --- a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java +++ b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java @@ -261,5 +261,19 @@ public class GamesTest extends TestCase { String actual = testObject.checkUskEighteen(); assertEquals(expected, actual); } + + public void test_checkPegiThree() { + Games testObject = new Games(); + String expected = "Ratchet & Clank, Rhythm Paradise, Tomodachi Life, Beautiful Katamari"; + String actual = testObject.checkPegiThree(); + assertEquals(expected, actual); + } + + public void test_checkPegiSeven() { + Games testObject = new Games(); + String expected = "Crash Bandicoot N. Sane Trilogy"; + String actual = testObject.checkPegiSeven(); + assertEquals(expected, actual); + } }