Browse Source

Added EU Publisher Check + Test

dev
Adem Berber 3 years ago
parent
commit
1b6402a527
  1. 43
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 7
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

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

@ -830,4 +830,47 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkPublishersEu() {
String result = "";
String query = "SELECT Game_Publisher_EU FROM Games";
boolean sega = false;
boolean nintendo = false;
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
if (sega && gamePublisherEu.equals("Sega")) {
continue;
} else if (nintendo && gamePublisherEu.equals("Nintendo")) {
continue;
}
switch (gamePublisherEu) {
case "Sega":
sega = true;
break;
case "Nintendo":
nintendo = true;
break;
}
result += gamePublisherEu + ", ";
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
}

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

@ -142,4 +142,11 @@ public class GamesTest extends TestCase {
String actual = testObject.checkPublishers();
assertEquals(expected, actual);
}
public void test_checkPublishersEu() {
Games testObject = new Games();
String expected = "Sega, Sony Computer Entertainment, Nintendo, Electronic Arts, Numskull Games, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Activision";
String actual = testObject.checkPublishersEu();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save