From 0ec0d840cc4b2d8869ee1e53a4d31e2545b6be2d Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Tue, 15 Feb 2022 02:13:39 +0100 Subject: [PATCH] Added ESRB Checkers + Tests --- projjpn/GamesDB.accdb | Bin 1015808 -> 1015808 bytes projjpn/GamesDB.laccdb | Bin 64 -> 0 bytes .../java/de/hs_fulda/ciip/projjpn/Games.java | 58 ++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 14 +++++ 4 files changed, 72 insertions(+) diff --git a/projjpn/GamesDB.accdb b/projjpn/GamesDB.accdb index 380bfb7e9108dd721ab2a676ca9268ab7e907647..e67a55652846dc806f2bbac3ea7ba361b11006b5 100644 GIT binary patch delta 134 zcmZo@uxn_r+rY%fq`|UTfbRq2WCcE+CV_1Nj3@Y5dk)C@9h`nvj!}{^uKl?jBM>tI zF*6XeY=17tD!q`0liMfE(T4#D;u)q39AI5FUEu($(Dq#iSRb&puR6{O#2}g-h&h0m V6NtHhm>Y6x057;Jd5NKa@oE3=KfS4VKIe?fG Uh`E568;E&;n0NcC<9uN|0H&ximjD0& diff --git a/projjpn/GamesDB.laccdb b/projjpn/GamesDB.laccdb index 5a03e0388674df9c401c0cef4dc38d6267f63454..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 GIT binary patch literal 0 HcmV?d00001 literal 64 icmZ>94fYQ45771WG4%0wG-gmh1CA-VnRytZ2t@#)Zwp2M 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 ea9678e..626ed15 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 @@ -1643,4 +1643,62 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkEsrbE() { + 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("E")) { + result += gameName + ", "; + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } + + public String checkEsrbEten() { + 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("E10+")) { + 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 cf601c1..f6e6b07 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 @@ -303,4 +303,18 @@ public class GamesTest extends TestCase { String actual = testObject.checkPegiUnknown(); assertEquals(expected, actual); } + + public void test_checkEsrbE() { + Games testObject = new Games(); + String expected = "Rhythm Paradise, Tomodachi Life, Beautiful Katamari"; + String actual = testObject.checkEsrbE(); + assertEquals(expected, actual); + } + + public void test_checkEsrbEten() { + Games testObject = new Games(); + String expected = "Super Smash Bros. Ultimate, Crash Bandicoot N. Sane Trilogy"; + String actual = testObject.checkEsrbEten(); + assertEquals(expected, actual); + } }