Browse Source

Added Game Genre Checker + Test

dev
Adem Berber 3 years ago
parent
commit
ea4247f42e
  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

@ -249,4 +249,47 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkGameGenres() {
String result = "";
String query = "SELECT Game_Genre FROM Games";
boolean actAd = false;
boolean rpg = false;
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameGenre = resultSet.getString("Game_Genre");
if (actAd && gameGenre.equals("Action-Adventure")) {
continue;
} else if (rpg && gameGenre.equals("RPG")) {
continue;
}
switch (gameGenre) {
case "Action-Adventure":
actAd = true;
break;
case "RPG":
rpg = true;
break;
}
result += gameGenre + ", ";
}
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

@ -51,4 +51,11 @@ public class GamesTest extends TestCase {
String actual = testObject.checkAllDifferentReleaseDates(); String actual = testObject.checkAllDifferentReleaseDates();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkGameGenres() {
Games testObject = new Games();
String expected = "JRPG, Action-Adventure, Tactical role-playing, Strategy, Rhythm, Fighting, Survival Horror, Action, Adventure, RPG, Life Simulation, Puzzle, Platformer";
String actual = testObject.checkGameGenres();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save