Browse Source

Added Specific Console Checkers + Tests

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

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

@ -350,4 +350,68 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkConsolePlayStation() {
String result = "";
String query = "SELECT Game_Name, Game_Console 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 gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() > 11) {
if (gameConsole.substring(0, 11).equals("PlayStation")) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkConsoleNintendo() {
String result = "";
String query = "SELECT Game_Name, Game_Console 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 gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() > 8) {
if (gameConsole.substring(0, 8).equals("Nintendo")) {
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

@ -72,4 +72,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkGameGenreRPG(); String actual = testObject.checkGameGenreRPG();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkConsolePlayStation() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkConsolePlayStation();
assertEquals(expected, actual);
}
public void test_checkConsoleNintendo() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Tomodachi Life";
String actual = testObject.checkConsoleNintendo();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save