From 1b6402a527dd202ec4960ca36c3b346f7f85b1ef Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 22:01:33 +0100 Subject: [PATCH] Added EU Publisher Check + Test --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 43 +++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 7 +++ 2 files changed, 50 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 c6abbfc..c85f6ea 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 @@ -830,4 +830,47 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkPublishersEu() { + String result = ""; + String query = "SELECT Game_Publisher_EU FROM Games"; + boolean sega = false; + boolean nintendo = false; + + try { + Connection connection = DriverManager.getConnection(databaseURL); + + Statement statement = connection.createStatement(); + ResultSet resultSet = statement.executeQuery(query); + + while (resultSet.next()) { + String gamePublisherEu = resultSet.getString("Game_Publisher_EU"); + + if (sega && gamePublisherEu.equals("Sega")) { + continue; + } else if (nintendo && gamePublisherEu.equals("Nintendo")) { + continue; + } + + switch (gamePublisherEu) { + case "Sega": + sega = true; + break; + case "Nintendo": + nintendo = true; + break; + } + + result += gamePublisherEu + ", "; + + } + 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 6b68266..ff3edff 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 @@ -142,4 +142,11 @@ public class GamesTest extends TestCase { String actual = testObject.checkPublishers(); assertEquals(expected, actual); } + + public void test_checkPublishersEu() { + Games testObject = new Games(); + String expected = "Sega, Sony Computer Entertainment, Nintendo, Electronic Arts, Numskull Games, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Activision"; + String actual = testObject.checkPublishersEu(); + assertEquals(expected, actual); + } }