Browse Source

Added additional USK Checkers + Tests

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

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

@ -1353,4 +1353,62 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkUskSix() {
String result = "";
String query = "SELECT Game_Name, Game_USK_Rating 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");
int gameUsk = resultSet.getInt("Game_USK_Rating");
if (gameUsk == 6) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkUskTwelve() {
String result = "";
String query = "SELECT Game_Name, Game_USK_Rating 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");
int gameUsk = resultSet.getInt("Game_USK_Rating");
if (gameUsk == 12) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
} }

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

@ -233,4 +233,19 @@ public class GamesTest extends TestCase {
String actual = testObject.checkUskZero(); String actual = testObject.checkUskZero();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkUskSix() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkUskSix();
assertEquals(expected, actual);
}
public void test_checkUskTwelve() {
Games testObject = new Games();
String expected = "Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, Jet Set Radio Future, Persona 3 Portable";
String actual = testObject.checkUskTwelve();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save