From 2521e7d5da4ada219bbef097cdfb576537472b4f Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 21:06:41 +0100 Subject: [PATCH] Added Publisher Check + Test --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 183 ++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 7 + 2 files changed, 190 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 86cce3d..c6abbfc 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 @@ -647,4 +647,187 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkPublishers() { + String result = ""; + String query = "SELECT Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games"; + boolean sega = false; + boolean atlus = false; + boolean sce = false; + boolean nintendo = false; + boolean namco = false; + boolean spikeChun = false; + boolean bandaiNamco = false; + boolean activision = false; + boolean whileSwitchOne = true; + boolean whileSwitchTwo = true; + + 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"); + String gamePublisherJp = resultSet.getString("Game_Publisher_JP"); + String gamePublisherNa = resultSet.getString("Game_Publisher_NA"); + + while (whileSwitchOne) { + while (whileSwitchTwo) { + if (sega && gamePublisherEu.equals("Sega")) { + break; + } else if (atlus && gamePublisherEu.equals("Atlus")) { + break; + } else if (sce && gamePublisherEu.equals("Sony Computer Entertainment")) { + break; + } else if (nintendo && gamePublisherEu.equals("Nintendo")) { + break; + } else if (namco && gamePublisherEu.equals("Namco")) { + break; + } else if (spikeChun && gamePublisherEu.equals("Spike Chunsoft")) { + break; + } else if (bandaiNamco && gamePublisherEu.equals("Bandai Namco Games")) { + break; + } else if (activision && gamePublisherEu.equals("Activision")) { + break; + } + + switch (gamePublisherEu) { + case "Sega": + sega = true; + break; + case "Atlus": + atlus = true; + break; + case "Sony Computer Entertainment": + sce = true; + break; + case "Nintendo": + nintendo = true; + break; + case "Namco": + namco = true; + break; + case "Spike Chunsoft": + spikeChun = true; + break; + case "Bandai Namco Games": + bandaiNamco = true; + break; + case "Activision": + activision = true; + break; + } + + result += gamePublisherEu + ", "; + break; + } + if (sega && gamePublisherJp.equals("Sega")) { + break; + } else if (atlus && gamePublisherJp.equals("Atlus")) { + break; + } else if (sce && gamePublisherJp.equals("Sony Computer Entertainment")) { + break; + } else if (nintendo && gamePublisherJp.equals("Nintendo")) { + break; + } else if (namco && gamePublisherJp.equals("Namco")) { + break; + } else if (spikeChun && gamePublisherJp.equals("Spike Chunsoft")) { + break; + } else if (bandaiNamco && gamePublisherJp.equals("Bandai Namco Games")) { + break; + } else if (activision && gamePublisherJp.equals("Activision")) { + break; + } + + switch (gamePublisherJp) { + case "Sega": + sega = true; + break; + case "Atlus": + atlus = true; + break; + case "Sony Computer Entertainment": + sce = true; + break; + case "Nintendo": + nintendo = true; + break; + case "Namco": + namco = true; + break; + case "Spike Chunsoft": + spikeChun = true; + break; + case "Bandai Namco Games": + bandaiNamco = true; + break; + case "Activision": + activision = true; + break; + } + + result += gamePublisherJp + ", "; + break; + } + if (sega && gamePublisherNa.equals("Sega")) { + continue; + } else if (atlus && gamePublisherNa.equals("Atlus")) { + continue; + } else if (sce && gamePublisherNa.equals("Sony Computer Entertainment")) { + continue; + } else if (nintendo && gamePublisherNa.equals("Nintendo")) { + continue; + } else if (namco && gamePublisherNa.equals("Namco")) { + continue; + } else if (spikeChun && gamePublisherNa.equals("Spike Chunsoft")) { + continue; + } else if (bandaiNamco && gamePublisherNa.equals("Bandai Namco Games")) { + continue; + } else if (activision && gamePublisherNa.equals("Activision")) { + continue; + } + + switch (gamePublisherNa) { + case "Sega": + sega = true; + break; + case "Atlus": + atlus = true; + break; + case "Sony Computer Entertainment": + sce = true; + break; + case "Nintendo": + nintendo = true; + break; + case "Namco": + namco = true; + break; + case "Spike Chunsoft": + spikeChun = true; + break; + case "Bandai Namco Games": + bandaiNamco = true; + break; + case "Activision": + activision = 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 d155b17..6b68266 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 @@ -135,4 +135,11 @@ public class GamesTest extends TestCase { String actual = testObject.checkPublisherSega(); assertEquals(expected, actual); } + + public void test_checkPublishers() { + Games testObject = new Games(); + String expected = "Sega, Atlus, Sony Computer Entertainment, Nintendo, Square Enix, Electronic Arts, Namco, Numskull Games, Spike Chunsoft, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Gust Co. Ltd., Tecmo Koei America, Activision"; + String actual = testObject.checkPublishers(); + assertEquals(expected, actual); + } }