From cf04d5dc45d223ffdae24ee4d93fe97184761516 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Thu, 17 Feb 2022 21:56:02 +0100 Subject: [PATCH 1/3] Fixed Missing Test --- .../de/hs_fulda/ciip/projjpn/GamesTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 db015f7..cfc7052 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 @@ -401,4 +401,28 @@ 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" + + "\n" + + "Persona 5 Royal, PlayStation 4, Atlus, Sega, Atlus, Atlus, JRPG, 31.03.2020, 31.10.2019, 31.03.2020, 31.03.2020, 16, 16, M, C, MA 15+, 1\n" + + "Ratchet & Clank, Multiplatform, Insomniac Games, Sony Computer Entertainment, Sony Computer Entertainment, Sony Computer Entertainment, Action-Adventure, 08.11.2002, 03.12.2002, 04.11.2002, 08.11.2002, 6, 3, T, A, PG, 1\n" + + "Astral Chain, Nintendo Switch, Platinum Games, Nintendo, Nintendo, Nintendo, Action-Adventure, 30.08.2019, 30.08.2019, 30.08.2019, 30.08.2019, 16, 16, T, C, M, 1-2\n" + + "Fire Emblem: Three Houses, Nintendo Switch, Intelligent Systems, Nintendo, Nintendo, Nintendo, Tactical role-playing, 26.07.2019, 26.07.2019, 26.07.2019, 26.07.2019, 12, 12, T, B, M, 1\n" + + "Triangle Strategy, Nintendo Switch, Artdink, Nintendo, Square Enix, Nintendo, Strategy, 04.03.2022, 04.03.2022, 04.03.2022, 04.03.2022, 12, 12, T, C, M, 1\n" + + "Rhythm Paradise, Nintendo DS, Nintendo SPD, Nintendo, Nintendo, Nintendo, Rhythm, 01.05.2009, 31.07.2008, 05.04.2009, 04.06.2009, 0, 3, E, A, G, 1\n" + + "Super Smash Bros. Ultimate, Nintendo Switch, Sora Ltd., Nintendo, Nintendo, Nintendo, Fighting, 07.12.2018, 07.12.2018, 07.12.2018, 07.12.2018, 12, 12, E10+, A, PG, 1-8\n" + + "Yakuza: Dead Souls, PlayStation 3, Ryu Ga Gotoku Studio, Sega, Sega, Sega, Survival Horror, 16.03.2012, 09.06.2011, 13.03.2012, 15.03.2012, 18, 18, M, D, MA 15+, 1\n" + + "Jet Set Radio Future, Xbox, Sega Sports R&D, Sega, Sega, Sega, Action, 14.03.2002, 22.02.2002, 25.02.2002, 14.03.2002, 12, Unknown, T, A, M, 1-4\n" + + "Breakdown, Xbox, Namco, Electronic Arts, Namco, Namco, Action-Adventure, 18.06.2004, 29.01.2004, 16.03.2004, Unknown, 16, 18, M, C, MA 15+, 1\n" + + "AI: The Somnium Files, Multiplatform, Spike Chunsoft, Numskull Games, Spike Chunsoft, Spike Chunsoft, Adventure, 20.09.2019, 19.09.2019, 17.09.2019, 20.09.2019, 16, 18, M, Z, MA 15+, 1\n" + + "Persona 3 Portable, PlayStation Portable, Atlus, Ghostlight, Atlus, Atlus, RPG, 29.04.2011, 01.11.2009, 06.07.2010, 16.11.2011, 12, 12, M, B, MA 15+, 1\n" + + "Tomodachi Life, Nintendo 3DS, Nintendo SPD, Nintendo, Nintendo, Nintendo, Life Simulation, 06.06.2014, 18.04.2013, 06.06.2014, 07.06.2014, 0, 3, E, A, PG, 1\n" + + "Beautiful Katamari, Xbox 360, Bandai Namco Games, Bandai Namco Games, Bandai Namco Games, Bandai Namco Games, Puzzle, 29.02.2008, 16.10.2007, 18.10.2007, 07.03.2008, 0, 3, E, A, G, 1\n" + + "Atelier Totori Plus, PlayStation Vita, Gust Co. Ltd., Tecmo Koei Europe, Gust Co. Ltd., Tecmo Koei America, RPG, 20.03.2013, 29.11.2012, 19.03.2013, Unknown, 6, 12, T, B, R 18+, 1\n" + + "Crash Bandicoot N. Sane Trilogy, Multiplatform, Vicarious Visions, Activision, Activision, Activision, Platformer, 30.06.2017, 03.08.2017, 30.06.2017, 30.06.2017, 6, 7, E10+, A, PG, 1"; + String actual = testObject.printTable(); + assertEquals(expected, actual); + } } From a4ce780b4e8604b669f423abe7b39bb67899b09a Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Thu, 17 Feb 2022 22:13:33 +0100 Subject: [PATCH 2/3] Added Same Release Month Checker + Tests + Javadoc --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 47 +++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 7 +++ 2 files changed, 54 insertions(+) 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 994a3c0..9e433fa 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 @@ -1332,6 +1332,53 @@ public class Games { return result.substring(0, result.length() - 2); } + + /** + * Checks if the release years are all the same across Europe, Japan, North + * America and Australia. + * + * @return Prints the games which have the same release year. + */ + public String checkAllSameReleaseMonth() { + 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) { + + } 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 cfc7052..7e9107e 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,6 +191,13 @@ 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"; + String actual = testObject.checkAllSameReleaseMonth(); + assertEquals(expected, actual); + } public void test_checkOnePlayer() { Games testObject = new Games(); From 432211464b5864f2ba3bcffa7a6e27d691ae2d84 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Thu, 17 Feb 2022 22:21:02 +0100 Subject: [PATCH 3/3] 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"