Browse Source

Added Release Year Checkers + Tests

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

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

@ -1023,4 +1023,80 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkAllSameReleaseYear() {
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(0, 4).equals(gameReleaseJp.substring(0, 4)) && gameReleaseJp.substring(0, 4).equals(gameReleaseNa.substring(0, 4))
&& gameReleaseEu.substring(0, 4).equals(gameReleaseNa.substring(0, 4)) && gameReleaseAu.substring(0, 4).equals(gameReleaseEu.substring(0, 4))
&& gameReleaseAu.substring(0, 4).equals(gameReleaseJp.substring(0, 4)) && gameReleaseAu.substring(0, 4).equals(gameReleaseNa.substring(0, 4))) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkAllDifferentReleaseYear() {
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(0, 4).equals(gameReleaseJp.substring(0, 4)) || !gameReleaseJp.substring(0, 4).equals(gameReleaseNa.substring(0, 4))
|| !gameReleaseEu.substring(0, 4).equals(gameReleaseNa.substring(0, 4)) || !gameReleaseAu.substring(0, 4).equals(gameReleaseEu.substring(0, 4))
|| !gameReleaseAu.substring(0, 4).equals(gameReleaseJp.substring(0, 4)) || !gameReleaseAu.substring(0, 4).equals(gameReleaseNa.substring(0, 4))) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
}

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

@ -177,4 +177,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkReleaseDateUnknown();
assertEquals(expected, actual);
}
public void test_checkAllSameReleaseYear() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, Jet Set Radio Future, AI: The Somnium Files, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkAllSameReleaseYear();
assertEquals(expected, actual);
}
public void test_checkAllDifferentReleaseYear() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Rhythm Paradise, Yakuza: Dead Souls, Breakdown, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus";
String actual = testObject.checkAllDifferentReleaseYear();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save