From d9d81f9d693d70acea9568504e7ce9f5684ab482 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 19:51:37 +0100 Subject: [PATCH] Added Specific Publisher Checkers + Tests --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 64 +++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 14 ++++ 2 files changed, 78 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 ec367ab..1757c0f 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 @@ -581,4 +581,68 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkPublisherNintendo() { + String result = ""; + String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA 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 gamePublisherEu = resultSet.getString("Game_Publisher_EU"); + String gamePublisherJp = resultSet.getString("Game_Publisher_JP"); + String gamePublisherNa = resultSet.getString("Game_Publisher_NA"); + + if (gamePublisherEu.equals("Nintendo") || gamePublisherJp.equals("Nintendo") || gamePublisherNa.equals("Nintendo")) { + result += gameName + ", "; + + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } + + public String checkPublisherSega() { + String result = ""; + String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA 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 gamePublisherEu = resultSet.getString("Game_Publisher_EU"); + String gamePublisherJp = resultSet.getString("Game_Publisher_JP"); + String gamePublisherNa = resultSet.getString("Game_Publisher_NA"); + + if (gamePublisherEu.equals("Sega") || gamePublisherJp.equals("Sega") || gamePublisherNa.equals("Sega")) { + 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 bb0b6b8..f2fe48a 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 @@ -121,4 +121,18 @@ public class GamesTest extends TestCase { String actual = testObject.checkDevelopers(); assertEquals(expected, actual); } + + public void test_checkPublisherNintendo() { + Games testObject = new Games(); + String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Tomodachi Life"; + String actual = testObject.checkPublisherNintendo(); + assertEquals(expected, actual); + } + + public void test_checkPublisherSega() { + Games testObject = new Games(); + String expected = "Persona 5 Royal, Yakuza: Dead Souls, Jet Set Radio Future"; + String actual = testObject.checkPublisherSega(); + assertEquals(expected, actual); + } }