Browse Source

Added Publisher + Dev checker + Test

dev
Adem Berber 2 years ago
parent
commit
9c913e1408
  1. BIN
      projjpn/GamesDB.laccdb
  2. 34
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  3. 7
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

BIN
projjpn/GamesDB.laccdb

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

@ -137,4 +137,38 @@ public class Games {
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
public String checkAllDifferentPublishersDeveloper() {
String result = "";
String query = "SELECT Game_Name, Game_Developer, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA 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 gameDeveloper = resultSet.getString("Game_Developer");
String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (gamePublisherEu.equals(gamePublisherJp) && gamePublisherJp.equals(gamePublisherNa) && gamePublisherEu.equals(gamePublisherNa) && gameDeveloper.equals(gamePublisherEu) && gameDeveloper.equals(gamePublisherJp) && gameDeveloper.equals(gamePublisherNa) ) {
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);
}
}

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

@ -29,4 +29,11 @@ public class GamesTest extends TestCase {
String actual = testObject.checkAllDifferentPublishers();
assertEquals(expected, actual);
}
public void test_checkAllSamePublishersDeveloper() {
Games testObject = new Games();
String expected = "Beautiful Katamari";
String actual = testObject.checkAllDifferentPublishersDeveloper();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save