From b1bb4b2ea181fc4a3cf0c29b04c2e1a3223585aa Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 22:09:20 +0100 Subject: [PATCH] Added JP and NA Publisher Checks + Tests --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 98 +++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 14 +++ 2 files changed, 112 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 c85f6ea..6c4f430 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 @@ -873,4 +873,102 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkPublishersJp() { + String result = ""; + String query = "SELECT Game_Publisher_JP FROM Games"; + boolean atlus = false; + boolean nintendo = false; + boolean sega = false; + + try { + Connection connection = DriverManager.getConnection(databaseURL); + + Statement statement = connection.createStatement(); + ResultSet resultSet = statement.executeQuery(query); + + while (resultSet.next()) { + String gamePublisherJp = resultSet.getString("Game_Publisher_JP"); + + if (atlus && gamePublisherJp.equals("Atlus")) { + continue; + } else if (nintendo && gamePublisherJp.equals("Nintendo")) { + continue; + } else if (sega && gamePublisherJp.equals("Sega")) { + continue; + } + + switch (gamePublisherJp) { + case "Atlus": + atlus = true; + break; + case "Nintendo": + nintendo = true; + break; + case "Sega": + sega = true; + break; + } + + result += gamePublisherJp + ", "; + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } + + public String checkPublishersNa() { + String result = ""; + String query = "SELECT Game_Publisher_NA FROM Games"; + boolean atlus = false; + boolean nintendo = false; + boolean sega = false; + + try { + Connection connection = DriverManager.getConnection(databaseURL); + + Statement statement = connection.createStatement(); + ResultSet resultSet = statement.executeQuery(query); + + while (resultSet.next()) { + String gamePublisherNa = resultSet.getString("Game_Publisher_Na"); + + if (atlus && gamePublisherNa.equals("Atlus")) { + continue; + } else if (nintendo && gamePublisherNa.equals("Nintendo")) { + continue; + } else if (sega && gamePublisherNa.equals("Sega")) { + continue; + } + + switch (gamePublisherNa) { + case "Atlus": + atlus = true; + break; + case "Nintendo": + nintendo = true; + break; + case "Sega": + sega = true; + break; + } + + result += gamePublisherNa + ", "; + + } + 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 ff3edff..667b734 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 @@ -149,4 +149,18 @@ public class GamesTest extends TestCase { String actual = testObject.checkPublishersEu(); assertEquals(expected, actual); } + + public void test_checkPublishersJp() { + Games testObject = new Games(); + String expected = "Atlus, Sony Computer Entertainment, Nintendo, Square Enix, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Gust Co. Ltd., Activision"; + String actual = testObject.checkPublishersJp(); + assertEquals(expected, actual); + } + + public void test_checkPublishersNa() { + Games testObject = new Games(); + String expected = "Atlus, Sony Computer Entertainment, Nintendo, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Tecmo Koei America, Activision"; + String actual = testObject.checkPublishersNa(); + assertEquals(expected, actual); + } }