From 793305e873212d9b041b8204577287d3899ccdf4 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Tue, 15 Feb 2022 02:40:58 +0100 Subject: [PATCH] Added More Additional ACB 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 931f136..3bfac1f 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 @@ -1991,4 +1991,62 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkAcbMaFifteen() { + String result = ""; + String query = "SELECT Game_Name, Game_ACB_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 gameAcb = resultSet.getString("Game_ACB_Rating"); + + if (gameAcb.equals("MA 15+")) { + result += gameName + ", "; + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } + + public String checkAcbReighteen() { + String result = ""; + String query = "SELECT Game_Name, Game_ACB_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 gameAcb = resultSet.getString("Game_ACB_Rating"); + + if (gameAcb.equals("R 18+")) { + 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 f6f1436..69b923b 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 @@ -387,4 +387,18 @@ public class GamesTest extends TestCase { String actual = testObject.checkAcbM(); assertEquals(expected, actual); } + + public void test_checkAcbMaFifteen() { + Games testObject = new Games(); + String expected = "Persona 5 Royal, Yakuza: Dead Souls, Breakdown, AI: The Somnium Files, Persona 3 Portable"; + String actual = testObject.checkAcbMaFifteen(); + assertEquals(expected, actual); + } + + public void test_checkAcbReighteen() { + Games testObject = new Games(); + String expected = "Atelier Totori Plus"; + String actual = testObject.checkAcbReighteen(); + assertEquals(expected, actual); + } }