Browse Source

Refactored Class and Test File

dev
Adem Berber 3 years ago
parent
commit
f382b61b07
  1. 28
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 10
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

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

@ -478,7 +478,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkConsoleNintendoSwitch() { public String checkConsoleNintendoSwitch() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games"; String query = "SELECT Game_Name, Game_Console FROM Games";
@ -493,8 +493,8 @@ public class Games {
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.equals("Nintendo Switch")) {
result += gameName + ", ";
if (gameConsole.equals("Nintendo Switch")) {
result += gameName + ", ";
} }
@ -508,7 +508,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkDeveloperAtlus() { public String checkDeveloperAtlus() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Developer FROM Games"; String query = "SELECT Game_Name, Game_Developer FROM Games";
@ -523,8 +523,8 @@ public class Games {
String gameName = resultSet.getString("Game_Name"); String gameName = resultSet.getString("Game_Name");
String gameDeveloper = resultSet.getString("Game_Developer"); String gameDeveloper = resultSet.getString("Game_Developer");
if (gameDeveloper.equals("Atlus")) {
result += gameName + ", ";
if (gameDeveloper.equals("Atlus")) {
result += gameName + ", ";
} }
@ -538,7 +538,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkDevelopers() { public String checkDevelopers() {
String result = ""; String result = "";
String query = "SELECT Game_Developer FROM Games"; String query = "SELECT Game_Developer FROM Games";
@ -581,7 +581,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPublisherNintendo() { public String checkPublisherNintendo() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games"; String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games";
@ -598,8 +598,9 @@ public class Games {
String gamePublisherJp = resultSet.getString("Game_Publisher_JP"); String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA"); String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (gamePublisherEu.equals("Nintendo") || gamePublisherJp.equals("Nintendo") || gamePublisherNa.equals("Nintendo")) {
result += gameName + ", ";
if (gamePublisherEu.equals("Nintendo") || gamePublisherJp.equals("Nintendo")
|| gamePublisherNa.equals("Nintendo")) {
result += gameName + ", ";
} }
@ -613,7 +614,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPublisherSega() { public String checkPublisherSega() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games"; String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games";
@ -630,8 +631,9 @@ public class Games {
String gamePublisherJp = resultSet.getString("Game_Publisher_JP"); String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA"); String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (gamePublisherEu.equals("Sega") || gamePublisherJp.equals("Sega") || gamePublisherNa.equals("Sega")) {
result += gameName + ", ";
if (gamePublisherEu.equals("Sega") || gamePublisherJp.equals("Sega")
|| gamePublisherNa.equals("Sega")) {
result += gameName + ", ";
} }

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

@ -100,35 +100,35 @@ public class GamesTest extends TestCase {
String actual = testObject.checkConsoleMultiplatform(); String actual = testObject.checkConsoleMultiplatform();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkConsoleNintendoSwitch() { public void test_checkConsoleNintendoSwitch() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate"; String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate";
String actual = testObject.checkConsoleNintendoSwitch(); String actual = testObject.checkConsoleNintendoSwitch();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkDeveloperAtlus() { public void test_checkDeveloperAtlus() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Persona 5 Royal, Persona 3 Portable"; String expected = "Persona 5 Royal, Persona 3 Portable";
String actual = testObject.checkDeveloperAtlus(); String actual = testObject.checkDeveloperAtlus();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkDevelopers() { public void test_checkDevelopers() {
Games testObject = new Games(); 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 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(); String actual = testObject.checkDevelopers();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPublisherNintendo() { public void test_checkPublisherNintendo() {
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.checkPublisherNintendo(); String actual = testObject.checkPublisherNintendo();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPublisherSega() { public void test_checkPublisherSega() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Jet Set Radio Future"; String expected = "Persona 5 Royal, Yakuza: Dead Souls, Jet Set Radio Future";

Loading…
Cancel
Save