From adf9fa953b961d3826c9b6123c584096afcfd45a Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Mon, 14 Feb 2022 00:41:53 +0100 Subject: [PATCH] Added additional USK Checkers + Tests --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 58 +++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 15 +++++ 2 files changed, 73 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 44217bf..b8b9f2f 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 @@ -1353,4 +1353,62 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkUskSix() { + String result = ""; + String query = "SELECT Game_Name, Game_USK_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 gameUsk = resultSet.getInt("Game_USK_Rating"); + + if (gameUsk == 6) { + result += gameName + ", "; + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } + + public String checkUskTwelve() { + String result = ""; + String query = "SELECT Game_Name, Game_USK_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 gameUsk = resultSet.getInt("Game_USK_Rating"); + + if (gameUsk == 12) { + 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 044b438..c15e6af 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 @@ -233,4 +233,19 @@ public class GamesTest extends TestCase { String actual = testObject.checkUskZero(); assertEquals(expected, actual); } + + public void test_checkUskSix() { + Games testObject = new Games(); + String expected = "Ratchet & Clank, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy"; + String actual = testObject.checkUskSix(); + assertEquals(expected, actual); + } + + public void test_checkUskTwelve() { + Games testObject = new Games(); + String expected = "Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, Jet Set Radio Future, Persona 3 Portable"; + String actual = testObject.checkUskTwelve(); + assertEquals(expected, actual); + } } +