Browse Source

Added Additional ACB Checkers + Tests

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

@ -1933,4 +1933,62 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkAcbPg() {
String result = "";
String query = "SELECT Game_Name, Game_ACB_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");
String gameAcb = resultSet.getString("Game_ACB_Rating");
if (gameAcb.equals("PG")) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkAcbM() {
String result = "";
String query = "SELECT Game_Name, Game_ACB_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");
String gameAcb = resultSet.getString("Game_ACB_Rating");
if (gameAcb.equals("M")) {
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

@ -373,4 +373,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkAcbG(); String actual = testObject.checkAcbG();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkAcbPg() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Super Smash Bros. Ultimate, Tomodachi Life, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkAcbPg();
assertEquals(expected, actual);
}
public void test_checkAcbM() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Jet Set Radio Future";
String actual = testObject.checkAcbM();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save