From 6ca90011547e5aa764b7d7ab81a6a706cd8262b6 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 03:45:01 +0100 Subject: [PATCH] Refactored Class and Test Class --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 34 +++++++++---------- .../de/hs_fulda/ciip/projjpn/GamesTest.java | 14 ++++---- 2 files changed, 24 insertions(+), 24 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 f676754..6b389ec 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 @@ -249,7 +249,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkGameGenres() { String result = ""; String query = "SELECT Game_Genre FROM Games"; @@ -292,7 +292,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkGameGenreActionAdventure() { String result = ""; String query = "SELECT Game_Name, Game_Genre FROM Games"; @@ -321,7 +321,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkGameGenreRPG() { String result = ""; String query = "SELECT Game_Name, Game_Genre FROM Games"; @@ -350,7 +350,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkConsolePlayStation() { String result = ""; String query = "SELECT Game_Name, Game_Console FROM Games"; @@ -364,14 +364,14 @@ public class Games { while (resultSet.next()) { String gameName = resultSet.getString("Game_Name"); String gameConsole = resultSet.getString("Game_Console"); - - if (gameConsole.length() > 11) { + + if (gameConsole.length() >= 11) { if (gameConsole.substring(0, 11).equals("PlayStation")) { result += gameName + ", "; } } - + } statement.close(); connection.close(); @@ -382,7 +382,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkConsoleNintendo() { String result = ""; String query = "SELECT Game_Name, Game_Console FROM Games"; @@ -396,14 +396,14 @@ public class Games { while (resultSet.next()) { String gameName = resultSet.getString("Game_Name"); String gameConsole = resultSet.getString("Game_Console"); - - if (gameConsole.length() > 8) { + + if (gameConsole.length() >= 8) { if (gameConsole.substring(0, 8).equals("Nintendo")) { result += gameName + ", "; } } - + } statement.close(); connection.close(); @@ -414,7 +414,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkConsoleXbox() { String result = ""; String query = "SELECT Game_Name, Game_Console FROM Games"; @@ -428,14 +428,14 @@ public class Games { while (resultSet.next()) { String gameName = resultSet.getString("Game_Name"); String gameConsole = resultSet.getString("Game_Console"); - + if (gameConsole.length() >= 4) { if (gameConsole.substring(0, 4).equals("Xbox")) { result += gameName + ", "; } } - + } statement.close(); connection.close(); @@ -446,7 +446,7 @@ public class Games { return result.substring(0, result.length() - 2); } - + public String checkConsoleMultiplatform() { String result = ""; String query = "SELECT Game_Name, Game_Console FROM Games"; @@ -460,14 +460,14 @@ public class Games { while (resultSet.next()) { String gameName = resultSet.getString("Game_Name"); String gameConsole = resultSet.getString("Game_Console"); - + if (gameConsole.length() >= 13) { if (gameConsole.substring(0, 13).equals("Multiplatform")) { result += gameName + ", "; } } - + } statement.close(); connection.close(); 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 987b63e..9168661 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 @@ -51,49 +51,49 @@ public class GamesTest extends TestCase { String actual = testObject.checkAllDifferentReleaseDates(); assertEquals(expected, actual); } - + public void test_checkGameGenres() { Games testObject = new Games(); String expected = "JRPG, Action-Adventure, Tactical role-playing, Strategy, Rhythm, Fighting, Survival Horror, Action, Adventure, RPG, Life Simulation, Puzzle, Platformer"; String actual = testObject.checkGameGenres(); assertEquals(expected, actual); } - + public void test_checkGameGenreActionAdventure() { Games testObject = new Games(); String expected = "Ratchet & Clank, Astral Chain, Breakdown"; String actual = testObject.checkGameGenreActionAdventure(); assertEquals(expected, actual); } - + public void test_checkGameGenreRPG() { Games testObject = new Games(); String expected = "Persona 3 Portable, Atelier Totori Plus"; String actual = testObject.checkGameGenreRPG(); assertEquals(expected, actual); } - + public void test_checkConsolePlayStation() { Games testObject = new Games(); String expected = "Persona 5 Royal, Yakuza: Dead Souls, Persona 3 Portable, Atelier Totori Plus"; String actual = testObject.checkConsolePlayStation(); assertEquals(expected, actual); } - + public void test_checkConsoleNintendo() { Games testObject = new Games(); String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Tomodachi Life"; String actual = testObject.checkConsoleNintendo(); assertEquals(expected, actual); } - + public void test_checkConsoleXbox() { Games testObject = new Games(); String expected = "Jet Set Radio Future, Breakdown, Beautiful Katamari"; String actual = testObject.checkConsoleXbox(); assertEquals(expected, actual); } - + public void test_checkConsoleMultiplatform() { Games testObject = new Games(); String expected = "Ratchet & Clank, AI: The Somnium Files, Crash Bandicoot N. Sane Trilogy";