Browse Source

Refactored Class and Test Class

dev
Adem Berber 3 years ago
parent
commit
6ca9001154
  1. 34
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 14
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

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

@ -249,7 +249,7 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkGameGenres() {
String result = "";
String query = "SELECT Game_Genre FROM Games";
@ -292,7 +292,7 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkGameGenreActionAdventure() {
String result = "";
String query = "SELECT Game_Name, Game_Genre FROM Games";
@ -321,7 +321,7 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkGameGenreRPG() {
String result = "";
String query = "SELECT Game_Name, Game_Genre FROM Games";
@ -350,7 +350,7 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkConsolePlayStation() {
String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games";
@ -364,14 +364,14 @@ public class Games {
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() > 11) {
if (gameConsole.length() >= 11) {
if (gameConsole.substring(0, 11).equals("PlayStation")) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
@ -382,7 +382,7 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkConsoleNintendo() {
String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games";
@ -396,14 +396,14 @@ public class Games {
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() > 8) {
if (gameConsole.length() >= 8) {
if (gameConsole.substring(0, 8).equals("Nintendo")) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
@ -414,7 +414,7 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkConsoleXbox() {
String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games";
@ -428,14 +428,14 @@ public class Games {
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() >= 4) {
if (gameConsole.substring(0, 4).equals("Xbox")) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
@ -446,7 +446,7 @@ public class Games {
return result.substring(0, result.length() - 2);
}
public String checkConsoleMultiplatform() {
String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games";
@ -460,14 +460,14 @@ public class Games {
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() >= 13) {
if (gameConsole.substring(0, 13).equals("Multiplatform")) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();

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

@ -51,49 +51,49 @@ public class GamesTest extends TestCase {
String actual = testObject.checkAllDifferentReleaseDates();
assertEquals(expected, actual);
}
public void test_checkGameGenres() {
Games testObject = new Games();
String expected = "JRPG, Action-Adventure, Tactical role-playing, Strategy, Rhythm, Fighting, Survival Horror, Action, Adventure, RPG, Life Simulation, Puzzle, Platformer";
String actual = testObject.checkGameGenres();
assertEquals(expected, actual);
}
public void test_checkGameGenreActionAdventure() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Breakdown";
String actual = testObject.checkGameGenreActionAdventure();
assertEquals(expected, actual);
}
public void test_checkGameGenreRPG() {
Games testObject = new Games();
String expected = "Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkGameGenreRPG();
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);
}
public void test_checkConsoleXbox() {
Games testObject = new Games();
String expected = "Jet Set Radio Future, Breakdown, Beautiful Katamari";
String actual = testObject.checkConsoleXbox();
assertEquals(expected, actual);
}
public void test_checkConsoleMultiplatform() {
Games testObject = new Games();
String expected = "Ratchet & Clank, AI: The Somnium Files, Crash Bandicoot N. Sane Trilogy";

Loading…
Cancel
Save