Browse Source

Added Specific Game Genre Checkers + Tests

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

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

@ -292,4 +292,62 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkGameGenreActionAdventure() {
String result = "";
String query = "SELECT Game_Name, Game_Genre 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 gameGenre = resultSet.getString("Game_Genre");
if (gameGenre.equals("Action-Adventure")) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkGameGenreRPG() {
String result = "";
String query = "SELECT Game_Name, Game_Genre 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 gameGenre = resultSet.getString("Game_Genre");
if (gameGenre.equals("RPG")) {
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

@ -58,4 +58,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkGameGenres();
assertEquals(expected, actual);
}
public void test_checkGameGenreActionAdventure() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Breakdown";
String actual = testObject.checkGameGenreActionAdventure();
assertEquals(expected, actual);
}
public void test_checkGameGenreRPG() {
Games testObject = new Games();
String expected = "Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkGameGenreRPG();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save