Browse Source

Added Developers Checker + Test

dev
Adem Berber 3 years ago
parent
commit
46d24fcdae
  1. 43
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 7
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

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

@ -538,4 +538,47 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkDevelopers() {
String result = "";
String query = "SELECT Game_Developer FROM Games";
boolean atlus = false;
boolean nintendoSpd = false;
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameDeveloper = resultSet.getString("Game_Developer");
if (atlus && gameDeveloper.equals("Atlus")) {
continue;
} else if (nintendoSpd && gameDeveloper.equals("Nintendo SPD")) {
continue;
}
switch (gameDeveloper) {
case "Atlus":
atlus = true;
break;
case "Nintendo SPD":
nintendoSpd = true;
break;
}
result += gameDeveloper + ", ";
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
} }

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

@ -114,4 +114,11 @@ public class GamesTest extends TestCase {
String actual = testObject.checkDeveloperAtlus(); String actual = testObject.checkDeveloperAtlus();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkDevelopers() {
Games testObject = new Games();
String expected = "Atlus, Insomniac Games, Platinum Games, Intelligent Systems, Artdink, Nintendo SPD, Sora Ltd., Ryu Ga Gotoku Studio, Sega Sports R&D, Namco, Spike Chunsoft, Bandai Namco Games, Gust Co. Ltd., Vicarious Visions";
String actual = testObject.checkDevelopers();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save