Browse Source

Refactored Class and Test Class

dev
Adem Berber 3 years ago
parent
commit
576c24abcd
  1. 182
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 1
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

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

@ -35,31 +35,29 @@ public class Games {
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameConsole = resultSet.getString("Game_Console");
if (ninSwitch && gameConsole.equals("Nintendo Switch")) {
continue;
} else if (xbox && gameConsole.equals("Xbox")) {
continue;
} else if (multiplat && gameConsole.equals("Multiplatform")) {
continue;
}
switch (gameConsole) {
case "Nintendo Switch":
ninSwitch = true;
break;
case "Xbox":
xbox = true;
break;
case "Multiplatform":
multiplat = true;
break;
}
result += gameConsole + ", ";
String gameConsole = resultSet.getString("Game_Console");
if (ninSwitch && gameConsole.equals("Nintendo Switch")) {
continue;
} else if (xbox && gameConsole.equals("Xbox")) {
continue;
} else if (multiplat && gameConsole.equals("Multiplatform")) {
continue;
}
switch (gameConsole) {
case "Nintendo Switch":
ninSwitch = true;
break;
case "Xbox":
xbox = true;
break;
case "Multiplatform":
multiplat = true;
break;
}
result += gameConsole + ", ";
}
statement.close();
@ -68,7 +66,7 @@ public class Games {
} catch (SQLException e) {
e.printStackTrace();
}
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
@ -83,16 +81,15 @@ public class Games {
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
String gameName = resultSet.getString("Game_Name");
String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (gamePublisherEu.equals(gamePublisherJp) && gamePublisherJp.equals(gamePublisherNa) && gamePublisherEu.equals(gamePublisherNa)) {
result += gameName + ", ";
}
if (gamePublisherEu.equals(gamePublisherJp) && gamePublisherJp.equals(gamePublisherNa)
&& gamePublisherEu.equals(gamePublisherNa)) {
result += gameName + ", ";
}
}
statement.close();
@ -101,7 +98,7 @@ public class Games {
} catch (SQLException e) {
e.printStackTrace();
}
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
@ -116,16 +113,15 @@ public class Games {
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
String gameName = resultSet.getString("Game_Name");
String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (!gamePublisherEu.equals(gamePublisherJp) && !gamePublisherJp.equals(gamePublisherNa) && !gamePublisherEu.equals(gamePublisherNa)) {
result += gameName + ", ";
}
if (!gamePublisherEu.equals(gamePublisherJp) && !gamePublisherJp.equals(gamePublisherNa)
&& !gamePublisherEu.equals(gamePublisherNa)) {
result += gameName + ", ";
}
}
statement.close();
@ -134,7 +130,7 @@ public class Games {
} catch (SQLException e) {
e.printStackTrace();
}
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
@ -149,17 +145,17 @@ public class Games {
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameDeveloper = resultSet.getString("Game_Developer");
String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (gamePublisherEu.equals(gamePublisherJp) && gamePublisherJp.equals(gamePublisherNa) && gamePublisherEu.equals(gamePublisherNa) && gameDeveloper.equals(gamePublisherEu) && gameDeveloper.equals(gamePublisherJp) && gameDeveloper.equals(gamePublisherNa) ) {
result += gameName + ", ";
}
String gameName = resultSet.getString("Game_Name");
String gameDeveloper = resultSet.getString("Game_Developer");
String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (gamePublisherEu.equals(gamePublisherJp) && gamePublisherJp.equals(gamePublisherNa)
&& gamePublisherEu.equals(gamePublisherNa) && gameDeveloper.equals(gamePublisherEu)
&& gameDeveloper.equals(gamePublisherJp) && gameDeveloper.equals(gamePublisherNa)) {
result += gameName + ", ";
}
}
statement.close();
@ -168,7 +164,7 @@ public class Games {
} catch (SQLException e) {
e.printStackTrace();
}
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
@ -183,23 +179,24 @@ public class Games {
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameReleaseEu = resultSet.getString("Game_Release_EU");
String gameReleaseJp = resultSet.getString("Game_Release_JP");
String gameReleaseNa = resultSet.getString("Game_Release_NA");
String gameReleaseAu = resultSet.getString("Game_Release_AU");
if (gameReleaseAu == null) {
if (gameReleaseEu.equals(gameReleaseJp) && gameReleaseJp.equals(gameReleaseNa) && gameReleaseEu.equals(gameReleaseNa)) {
result += gameName + ", ";
}
} else {
if (gameReleaseEu.equals(gameReleaseJp) && gameReleaseJp.equals(gameReleaseNa) && gameReleaseEu.equals(gameReleaseNa) && gameReleaseAu.equals(gameReleaseEu) && gameReleaseAu.equals(gameReleaseJp) && gameReleaseAu.equals(gameReleaseNa) ) {
result += gameName + ", ";
}
String gameName = resultSet.getString("Game_Name");
String gameReleaseEu = resultSet.getString("Game_Release_EU");
String gameReleaseJp = resultSet.getString("Game_Release_JP");
String gameReleaseNa = resultSet.getString("Game_Release_NA");
String gameReleaseAu = resultSet.getString("Game_Release_AU");
if (gameReleaseAu == null) {
if (gameReleaseEu.equals(gameReleaseJp) && gameReleaseJp.equals(gameReleaseNa)
&& gameReleaseEu.equals(gameReleaseNa)) {
result += gameName + ", ";
}
} else {
if (gameReleaseEu.equals(gameReleaseJp) && gameReleaseJp.equals(gameReleaseNa)
&& gameReleaseEu.equals(gameReleaseNa) && gameReleaseAu.equals(gameReleaseEu)
&& gameReleaseAu.equals(gameReleaseJp) && gameReleaseAu.equals(gameReleaseNa)) {
result += gameName + ", ";
}
}
}
statement.close();
@ -208,7 +205,7 @@ public class Games {
} catch (SQLException e) {
e.printStackTrace();
}
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
@ -223,23 +220,24 @@ public class Games {
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameReleaseEu = resultSet.getString("Game_Release_EU");
String gameReleaseJp = resultSet.getString("Game_Release_JP");
String gameReleaseNa = resultSet.getString("Game_Release_NA");
String gameReleaseAu = resultSet.getString("Game_Release_AU");
if (gameReleaseAu == null) {
if (!gameReleaseEu.equals(gameReleaseJp) && !gameReleaseJp.equals(gameReleaseNa) && !gameReleaseEu.equals(gameReleaseNa)) {
result += gameName + ", ";
}
} else {
if (!gameReleaseEu.equals(gameReleaseJp) && !gameReleaseJp.equals(gameReleaseNa) && !gameReleaseEu.equals(gameReleaseNa) && !gameReleaseAu.equals(gameReleaseEu) && !gameReleaseAu.equals(gameReleaseJp) && !gameReleaseAu.equals(gameReleaseNa) ) {
result += gameName + ", ";
}
String gameName = resultSet.getString("Game_Name");
String gameReleaseEu = resultSet.getString("Game_Release_EU");
String gameReleaseJp = resultSet.getString("Game_Release_JP");
String gameReleaseNa = resultSet.getString("Game_Release_NA");
String gameReleaseAu = resultSet.getString("Game_Release_AU");
if (gameReleaseAu == null) {
if (!gameReleaseEu.equals(gameReleaseJp) && !gameReleaseJp.equals(gameReleaseNa)
&& !gameReleaseEu.equals(gameReleaseNa)) {
result += gameName + ", ";
}
} else {
if (!gameReleaseEu.equals(gameReleaseJp) && !gameReleaseJp.equals(gameReleaseNa)
&& !gameReleaseEu.equals(gameReleaseNa) && !gameReleaseAu.equals(gameReleaseEu)
&& !gameReleaseAu.equals(gameReleaseJp) && !gameReleaseAu.equals(gameReleaseNa)) {
result += gameName + ", ";
}
}
}
statement.close();
@ -248,7 +246,7 @@ public class Games {
} catch (SQLException e) {
e.printStackTrace();
}
// The substring removes the last New line in the String.
return result.substring(0, result.length() - 2);
}
}

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

@ -1,4 +1,5 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class GamesTest extends TestCase {

Loading…
Cancel
Save