Browse Source

Added PEGI Checkers + Tests

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

@ -1469,4 +1469,62 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPegiThree() {
String result = "";
String query = "SELECT Game_Name, Game_PEGI_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 gamePegi = resultSet.getInt("Game_PEGI_Rating");
if (gamePegi == 3) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkPegiSeven() {
String result = "";
String query = "SELECT Game_Name, Game_PEGI_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 gamePegi = resultSet.getInt("Game_PEGI_Rating");
if (gamePegi == 7) {
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

@ -261,5 +261,19 @@ public class GamesTest extends TestCase {
String actual = testObject.checkUskEighteen(); String actual = testObject.checkUskEighteen();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPegiThree() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Rhythm Paradise, Tomodachi Life, Beautiful Katamari";
String actual = testObject.checkPegiThree();
assertEquals(expected, actual);
}
public void test_checkPegiSeven() {
Games testObject = new Games();
String expected = "Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkPegiSeven();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save