From 9c913e14083e41b72a918b7b97a13d9646e60843 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 02:00:23 +0100 Subject: [PATCH] Added Publisher + Dev checker + Test --- projjpn/GamesDB.laccdb | Bin 0 -> 64 bytes .../java/de/hs_fulda/ciip/projjpn/Games.java | 34 ++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 7 ++++ 3 files changed, 41 insertions(+) diff --git a/projjpn/GamesDB.laccdb b/projjpn/GamesDB.laccdb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5a03e0388674df9c401c0cef4dc38d6267f63454 100644 GIT binary patch literal 64 icmZ>94fYQ45771WG4%0wG-gmh1CA-VnRytZ2t@#)Zwp2M literal 0 HcmV?d00001 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 92078aa..584cc88 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 @@ -137,4 +137,38 @@ public class Games { // The substring removes the last New line in the String. return result.substring(0, result.length() - 2); } + + public String checkAllDifferentPublishersDeveloper() { + String result = ""; + String query = "SELECT Game_Name, Game_Developer, 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 gameDeveloper = resultSet.getString("Game_Developer"); + String gamePublisherEu = resultSet.getString("Game_Publisher_EU"); + String gamePublisherJp = resultSet.getString("Game_Publisher_JP"); + String gamePublisherNa = resultSet.getString("Game_Publisher_NA"); + + + + if (gamePublisherEu.equals(gamePublisherJp) && gamePublisherJp.equals(gamePublisherNa) && gamePublisherEu.equals(gamePublisherNa) && gameDeveloper.equals(gamePublisherEu) && gameDeveloper.equals(gamePublisherJp) && gameDeveloper.equals(gamePublisherNa) ) { + result += gameName + ", "; + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + // The substring removes the last New line in the String. + 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 c6755a8..8f9589c 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 @@ -29,4 +29,11 @@ public class GamesTest extends TestCase { String actual = testObject.checkAllDifferentPublishers(); assertEquals(expected, actual); } + + public void test_checkAllSamePublishersDeveloper() { + Games testObject = new Games(); + String expected = "Beautiful Katamari"; + String actual = testObject.checkAllDifferentPublishersDeveloper(); + assertEquals(expected, actual); + } }