From e8f46e214a70080a6d42e07d9272d4454645e071 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 23:09:48 +0100 Subject: [PATCH] Refactored Class and Test File --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 28 ++++++++----------- .../de/hs_fulda/ciip/projjpn/GamesTest.java | 12 ++++---- 2 files changed, 17 insertions(+), 23 deletions(-) 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 3be21e7..1e3c441 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 @@ -34,8 +34,6 @@ public class Games { while (resultSet.next()) { String gameName = resultSet.getString("Game_Name"); - - result += gameName + ", "; } @@ -48,7 +46,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkConsoles() { String result = ""; String query = "SELECT Game_Console FROM Games"; @@ -675,7 +673,7 @@ 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"; @@ -687,8 +685,6 @@ public class Games { boolean spikeChun = false; boolean bandaiNamco = false; boolean activision = false; - boolean whileSwitchOne = true; - boolean whileSwitchTwo = true; try { Connection connection = DriverManager.getConnection(databaseURL); @@ -700,9 +696,9 @@ public class Games { 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) { + + while (true) { + while (true) { if (sega && gamePublisherEu.equals("Sega")) { break; } else if (atlus && gamePublisherEu.equals("Atlus")) { @@ -846,8 +842,6 @@ public class Games { result += gamePublisherNa + ", "; - - } statement.close(); connection.close(); @@ -858,7 +852,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkPublishersEu() { String result = ""; String query = "SELECT Game_Publisher_EU FROM Games"; @@ -901,7 +895,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkPublishersJp() { String result = ""; String query = "SELECT Game_Publisher_JP FROM Games"; @@ -950,7 +944,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkPublishersNa() { String result = ""; String query = "SELECT Game_Publisher_NA FROM Games"; @@ -999,7 +993,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkReleaseDateUnknown() { String result = ""; String query = "SELECT Game_Name, Game_Release_AU FROM Games"; @@ -1015,8 +1009,8 @@ public class Games { String gameReleaseAu = resultSet.getString("Game_Release_AU"); if (gameReleaseAu == null) { - - result += gameName + ", "; + + result += gameName + ", "; } } 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 d4b2e69..8c52eea 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 @@ -9,7 +9,7 @@ public class GamesTest extends TestCase { boolean actual = testObject.checkConnection(); assertEquals(expected, actual); } - + public void test_checkGames() { Games testObject = new Games(); String expected = "Persona 5 Royal, Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Yakuza: Dead Souls, Jet Set Radio Future, Breakdown, AI: The Somnium Files, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy"; @@ -142,35 +142,35 @@ 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); } - + 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); } - + 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); } - + public void test_checkReleaseDateUnknown() { Games testObject = new Games(); String expected = "Breakdown, Atelier Totori Plus";