From 432211464b5864f2ba3bcffa7a6e27d691ae2d84 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Thu, 17 Feb 2022 22:21:02 +0100 Subject: [PATCH] Added Different Release Month Checker + Tests + Javadoc + Fixed Javadoc + Refactoring --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 76 +++++++++++++++---- .../de/hs_fulda/ciip/projjpn/GamesTest.java | 11 ++- 2 files changed, 70 insertions(+), 17 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 9e433fa..38172d4 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 @@ -42,8 +42,7 @@ public class Games { Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(query); - result += "Name, Console, Developer, Publisher EU, Publisher JP, Publisher NA, Genre, Release EU, Release JP, Release NA, Release AU, USK Rating, PEGI Rating, ESRB Rating, CERO Rating, ACB Rating, Players\n\n"; - + result += "Name, Console, Developer, Publisher EU, Publisher JP, Publisher NA, Genre, Release EU, Release JP, Release NA, Release AU, USK Rating, PEGI Rating, ESRB Rating, CERO Rating, ACB Rating, Players\n\n"; while (resultSet.next()) { String gameName = resultSet.getString("Game_Name"); @@ -82,17 +81,17 @@ public class Games { String gamePlayers = resultSet.getString("Game_Players"); if (gamePegi != 0) { - result += gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu - + ", " + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", " - + gameReleaseEuDots + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", " - + gameReleaseAuDots + ", " + gameUsk + ", " + gamePegi + ", " + gameEsrb + ", " + gameCero - + ", " + gameAcb + ", " + gamePlayers + "\n"; + result += gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu + ", " + + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", " + gameReleaseEuDots + + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", " + gameReleaseAuDots + ", " + + gameUsk + ", " + gamePegi + ", " + gameEsrb + ", " + gameCero + ", " + gameAcb + ", " + + gamePlayers + "\n"; } else { - result += gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu - + ", " + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", " - + gameReleaseEuDots + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", " - + gameReleaseAuDots + ", " + gameUsk + ", Unknown, " + gameEsrb + ", " + gameCero + ", " - + gameAcb + ", " + gamePlayers + "\n"; + result += gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu + ", " + + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", " + gameReleaseEuDots + + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", " + gameReleaseAuDots + ", " + + gameUsk + ", Unknown, " + gameEsrb + ", " + gameCero + ", " + gameAcb + ", " + gamePlayers + + "\n"; } } @@ -1332,12 +1331,12 @@ public class Games { return result.substring(0, result.length() - 2); } - + /** - * Checks if the release years are all the same across Europe, Japan, North + * Checks if the release months are all the same across Europe, Japan, North * America and Australia. * - * @return Prints the games which have the same release year. + * @return Prints the games which have the same release month. */ public String checkAllSameReleaseMonth() { String result = ""; @@ -1380,6 +1379,53 @@ public class Games { return result.substring(0, result.length() - 2); } + /** + * Checks if the release months are not all the same across Europe, Japan, North + * America and Australia. + * + * @return Prints the games which do not have the same release month. + */ + public String checkAllDifferentReleaseMonth() { + String result = ""; + String query = "SELECT Game_Name, Game_Release_EU, Game_Release_JP, Game_Release_NA, Game_Release_AU 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 gameReleaseEu = resultSet.getString("Game_Release_EU"); + String gameReleaseJp = resultSet.getString("Game_Release_JP"); + String gameReleaseNa = resultSet.getString("Game_Release_NA"); + String gameReleaseAu = resultSet.getString("Game_Release_AU"); + + if (gameReleaseAu == null) { + result += gameName + ", "; + } else { + if (!gameReleaseEu.substring(5, 7).equals(gameReleaseJp.substring(5, 7)) + || !gameReleaseJp.substring(5, 7).equals(gameReleaseNa.substring(5, 7)) + || !gameReleaseEu.substring(5, 7).equals(gameReleaseNa.substring(5, 7)) + || !gameReleaseAu.substring(5, 7).equals(gameReleaseEu.substring(5, 7)) + || !gameReleaseAu.substring(5, 7).equals(gameReleaseJp.substring(5, 7)) + || !gameReleaseAu.substring(5, 7).equals(gameReleaseNa.substring(5, 7))) { + result += gameName + ", "; + } + } + + } + statement.close(); + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + + return result.substring(0, result.length() - 2); + } + /** * Checks if the game is compatible with one player or more. * 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 7e9107e..c6a229d 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 @@ -191,7 +191,7 @@ public class GamesTest extends TestCase { String actual = testObject.checkAllDifferentReleaseYear(); assertEquals(expected, actual); } - + public void test_checkAllSameReleaseMonth() { Games testObject = new Games(); String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, AI: The Somnium Files"; @@ -199,6 +199,13 @@ public class GamesTest extends TestCase { assertEquals(expected, actual); } + public void test_checkAllDifferentReleaseMonth() { + Games testObject = new Games(); + String expected = "Persona 5 Royal, Ratchet & Clank, Rhythm Paradise, Yakuza: Dead Souls, Jet Set Radio Future, Breakdown, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy"; + String actual = testObject.checkAllDifferentReleaseMonth(); + assertEquals(expected, actual); + } + public void test_checkOnePlayer() { 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"; @@ -408,7 +415,7 @@ public class GamesTest extends TestCase { String actual = testObject.checkAcbReighteen(); assertEquals(expected, actual); } - + public void test_printTable() { Games testObject = new Games(); String expected = "Name, Console, Developer, Publisher EU, Publisher JP, Publisher NA, Genre, Release EU, Release JP, Release NA, Release AU, USK Rating, PEGI Rating, ESRB Rating, CERO Rating, ACB Rating, Players\n"