Browse Source

Added Release Date Checkers + Tests

dev
Adem Berber 3 years ago
parent
commit
49a3d044fa
  1. 80
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 14
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

80
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java

@ -171,4 +171,84 @@ public class Games {
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
public String checkAllSameReleaseDates() {
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) {
if (gameReleaseEu.equals(gameReleaseJp) && gameReleaseJp.equals(gameReleaseNa) && gameReleaseEu.equals(gameReleaseNa)) {
result += gameName + ", ";
}
} else {
if (gameReleaseEu.equals(gameReleaseJp) && gameReleaseJp.equals(gameReleaseNa) && gameReleaseEu.equals(gameReleaseNa) && gameReleaseAu.equals(gameReleaseEu) && gameReleaseAu.equals(gameReleaseJp) && gameReleaseAu.equals(gameReleaseNa) ) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
public String checkAllDifferentReleaseDates() {
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) {
if (!gameReleaseEu.equals(gameReleaseJp) && !gameReleaseJp.equals(gameReleaseNa) && !gameReleaseEu.equals(gameReleaseNa)) {
result += gameName + ", ";
}
} else {
if (!gameReleaseEu.equals(gameReleaseJp) && !gameReleaseJp.equals(gameReleaseNa) && !gameReleaseEu.equals(gameReleaseNa) && !gameReleaseAu.equals(gameReleaseEu) && !gameReleaseAu.equals(gameReleaseJp) && !gameReleaseAu.equals(gameReleaseNa) ) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
}

14
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

@ -36,4 +36,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkAllDifferentPublishersDeveloper();
assertEquals(expected, actual);
}
public void test_checkAllSameReleaseDates() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate";
String actual = testObject.checkAllSameReleaseDates();
assertEquals(expected, actual);
}
public void test_checkAllDifferentReleaseDates() {
Games testObject = new Games();
String expected = "Rhythm Paradise, Yakuza: Dead Souls, Breakdown, Persona 3 Portable, Beautiful Katamari, Atelier Totori Plus";
String actual = testObject.checkAllDifferentReleaseDates();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save