Browse Source

Refactored Class and Test Class

dev
Adem Berber 2 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); return result.substring(0, result.length() - 2);
} }
public String checkGameGenres() { public String checkGameGenres() {
String result = ""; String result = "";
String query = "SELECT Game_Genre FROM Games"; String query = "SELECT Game_Genre FROM Games";
@ -292,7 +292,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkGameGenreActionAdventure() { public String checkGameGenreActionAdventure() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Genre FROM Games"; String query = "SELECT Game_Name, Game_Genre FROM Games";
@ -321,7 +321,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkGameGenreRPG() { public String checkGameGenreRPG() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Genre FROM Games"; String query = "SELECT Game_Name, Game_Genre FROM Games";
@ -350,7 +350,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkConsolePlayStation() { public String checkConsolePlayStation() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games"; String query = "SELECT Game_Name, Game_Console FROM Games";
@ -364,14 +364,14 @@ public class Games {
while (resultSet.next()) { while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name"); String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console"); String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() > 11) {
if (gameConsole.length() >= 11) {
if (gameConsole.substring(0, 11).equals("PlayStation")) { if (gameConsole.substring(0, 11).equals("PlayStation")) {
result += gameName + ", "; result += gameName + ", ";
} }
} }
} }
statement.close(); statement.close();
connection.close(); connection.close();
@ -382,7 +382,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkConsoleNintendo() { public String checkConsoleNintendo() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games"; String query = "SELECT Game_Name, Game_Console FROM Games";
@ -396,14 +396,14 @@ public class Games {
while (resultSet.next()) { while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name"); String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console"); String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() > 8) {
if (gameConsole.length() >= 8) {
if (gameConsole.substring(0, 8).equals("Nintendo")) { if (gameConsole.substring(0, 8).equals("Nintendo")) {
result += gameName + ", "; result += gameName + ", ";
} }
} }
} }
statement.close(); statement.close();
connection.close(); connection.close();
@ -414,7 +414,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkConsoleXbox() { public String checkConsoleXbox() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games"; String query = "SELECT Game_Name, Game_Console FROM Games";
@ -428,14 +428,14 @@ public class Games {
while (resultSet.next()) { while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name"); String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console"); String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() >= 4) { if (gameConsole.length() >= 4) {
if (gameConsole.substring(0, 4).equals("Xbox")) { if (gameConsole.substring(0, 4).equals("Xbox")) {
result += gameName + ", "; result += gameName + ", ";
} }
} }
} }
statement.close(); statement.close();
connection.close(); connection.close();
@ -446,7 +446,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkConsoleMultiplatform() { public String checkConsoleMultiplatform() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games"; String query = "SELECT Game_Name, Game_Console FROM Games";
@ -460,14 +460,14 @@ public class Games {
while (resultSet.next()) { while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name"); String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console"); String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() >= 13) { if (gameConsole.length() >= 13) {
if (gameConsole.substring(0, 13).equals("Multiplatform")) { if (gameConsole.substring(0, 13).equals("Multiplatform")) {
result += gameName + ", "; result += gameName + ", ";
} }
} }
} }
statement.close(); statement.close();
connection.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(); String actual = testObject.checkAllDifferentReleaseDates();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkGameGenres() { public void test_checkGameGenres() {
Games testObject = new Games(); 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 expected = "JRPG, Action-Adventure, Tactical role-playing, Strategy, Rhythm, Fighting, Survival Horror, Action, Adventure, RPG, Life Simulation, Puzzle, Platformer";
String actual = testObject.checkGameGenres(); String actual = testObject.checkGameGenres();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkGameGenreActionAdventure() { public void test_checkGameGenreActionAdventure() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Breakdown"; String expected = "Ratchet & Clank, Astral Chain, Breakdown";
String actual = testObject.checkGameGenreActionAdventure(); String actual = testObject.checkGameGenreActionAdventure();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkGameGenreRPG() { public void test_checkGameGenreRPG() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Persona 3 Portable, Atelier Totori Plus"; String expected = "Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkGameGenreRPG(); String actual = testObject.checkGameGenreRPG();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkConsolePlayStation() { public void test_checkConsolePlayStation() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Persona 3 Portable, Atelier Totori Plus"; String expected = "Persona 5 Royal, Yakuza: Dead Souls, Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkConsolePlayStation(); String actual = testObject.checkConsolePlayStation();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkConsoleNintendo() { public void test_checkConsoleNintendo() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Tomodachi Life"; String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Tomodachi Life";
String actual = testObject.checkConsoleNintendo(); String actual = testObject.checkConsoleNintendo();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkConsoleXbox() { public void test_checkConsoleXbox() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Jet Set Radio Future, Breakdown, Beautiful Katamari"; String expected = "Jet Set Radio Future, Breakdown, Beautiful Katamari";
String actual = testObject.checkConsoleXbox(); String actual = testObject.checkConsoleXbox();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkConsoleMultiplatform() { public void test_checkConsoleMultiplatform() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Ratchet & Clank, AI: The Somnium Files, Crash Bandicoot N. Sane Trilogy"; String expected = "Ratchet & Clank, AI: The Somnium Files, Crash Bandicoot N. Sane Trilogy";

Loading…
Cancel
Save