From 1e96bf17371966a7d0287980e915b6ad0abd8fac Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Mon, 14 Feb 2022 00:54:15 +0100 Subject: [PATCH] Added more additional PEGI Checkers + Tests --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 58 +++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 14 +++++ 2 files changed, 72 insertions(+) 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 9c4683c..3ecf98a 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 @@ -1585,4 +1585,62 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkPegiEighteen() { + 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 == 18) { + result += gameName + ", "; + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } + + public String checkPegiUnknown() { + 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 == 0) { + 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 22bbb76..5b2603c 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 @@ -289,5 +289,19 @@ public class GamesTest extends TestCase { String actual = testObject.checkPegiSixteen(); assertEquals(expected, actual); } + + public void test_checkPegiEighteen() { + Games testObject = new Games(); + String expected = "Yakuza: Dead Souls, Breakdown, AI: The Somnium Files"; + String actual = testObject.checkPegiEighteen(); + assertEquals(expected, actual); + } + + public void test_checkPegiUnknown() { + Games testObject = new Games(); + String expected = "Jet Set Radio Future"; + String actual = testObject.checkPegiUnknown(); + assertEquals(expected, actual); + } }