From a2fe16c70306be5adb616183f2334f8bf7c3fbdf Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 19:21:54 +0100 Subject: [PATCH] Added Atlus Developer Checker + Test --- projjpn/GamesDB.laccdb | Bin 0 -> 64 bytes .../java/de/hs_fulda/ciip/projjpn/Games.java | 30 ++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 7 ++++ 3 files changed, 37 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 dab366d..aa5f764 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 @@ -508,4 +508,34 @@ public class Games { return result.substring(0, result.length() - 2); } + + public String checkDeveloperAtlus() { + String result = ""; + String query = "SELECT Game_Name, Game_Developer 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"); + + if (gameDeveloper.equals("Atlus")) { + 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 83d6fc7..66c06e2 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 @@ -107,4 +107,11 @@ public class GamesTest extends TestCase { String actual = testObject.checkConsoleNintendoSwitch(); assertEquals(expected, actual); } + + public void test_checkDeveloperAtlus() { + Games testObject = new Games(); + String expected = "Persona 5 Royal, Persona 3 Portable"; + String actual = testObject.checkDeveloperAtlus(); + assertEquals(expected, actual); + } }