Browse Source

Refactored Class and Test File

dev
Adem Berber 3 years ago
parent
commit
ae69414f36
  1. 108
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java

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

@ -32,48 +32,55 @@ public class Games {
ResultSet resultSet = statement.executeQuery(query); ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) { while (resultSet.next()) {
int id = resultSet.getInt("Game_ID");
String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console");
String gameDeveloper = resultSet.getString("Game_Developer");
String gamePublisherEu = resultSet.getString("Game_Developer");
String gamePublisherJp = resultSet.getString("Game_Console");
String gamePublisherNa = resultSet.getString("Game_Console");
String gameGenre = resultSet.getString("Game_Genre");
String gameReleaseEu = resultSet.getString("Game_Release_EU");
String gameReleaseEuDots = gameReleaseEu.substring(8, 10) + "." + gameReleaseEu.substring(5, 7)
+ "." + gameReleaseEu.substring(0, 4);
String gameReleaseJp = resultSet.getString("Game_Release_JP");
String gameReleaseJpDots = gameReleaseJp.substring(8, 10) + "." + gameReleaseJp.substring(5, 7)
+ "." + gameReleaseJp.substring(0, 4);
String gameReleaseNa = resultSet.getString("Game_Release_NA");
String gameReleaseNaDots = gameReleaseNa.substring(8, 10) + "." + gameReleaseNa.substring(5, 7)
+ "." + gameReleaseNa.substring(0, 4);
String gameReleaseAu = resultSet.getString("Game_Release_AU");
String gameReleaseAuDots;
if (gameReleaseAu != null) {
gameReleaseAuDots = gameReleaseAu.substring(8, 10) + "." + gameReleaseAu.substring(5, 7)
+ "." + gameReleaseAu.substring(0, 4);
} else {
gameReleaseAuDots = "Unknown";
}
int id = resultSet.getInt("Game_ID");
String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console");
String gameDeveloper = resultSet.getString("Game_Developer");
String gamePublisherEu = resultSet.getString("Game_Developer");
String gamePublisherJp = resultSet.getString("Game_Console");
String gamePublisherNa = resultSet.getString("Game_Console");
String gameGenre = resultSet.getString("Game_Genre");
int gameUsk = resultSet.getInt("Game_USK_Rating");
int gamePegi = resultSet.getInt("Game_PEGI_Rating");
String gameEsrb = resultSet.getString("Game_ESRB_Rating");
String gameCero = resultSet.getString("Game_CERO_Rating");
String gameAcb = resultSet.getString("Game_ACB_Rating");
String gamePlayers = resultSet.getString("Game_Players");
if (gamePegi != 0) {
result += id + ": " + gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu + ", " + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", " + gameReleaseEuDots + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", " + gameReleaseAuDots + ", " + gameUsk + ", " + gamePegi + ", " + gameEsrb + ", " + gameCero + ", " + gameAcb + ", " + gamePlayers + "\n";
} else {
result += id + ": " + gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu + ", " + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", " + gameReleaseEuDots + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", " + gameReleaseAuDots + ", " + gameUsk + ", Unknown, " + gameEsrb + ", " + gameCero + ", " + gameAcb + ", " + gamePlayers + "\n";
}
String gameReleaseEu = resultSet.getString("Game_Release_EU");
String gameReleaseEuDots = gameReleaseEu.substring(8, 10) + "." + gameReleaseEu.substring(5, 7) + "."
+ gameReleaseEu.substring(0, 4);
String gameReleaseJp = resultSet.getString("Game_Release_JP");
String gameReleaseJpDots = gameReleaseJp.substring(8, 10) + "." + gameReleaseJp.substring(5, 7) + "."
+ gameReleaseJp.substring(0, 4);
String gameReleaseNa = resultSet.getString("Game_Release_NA");
String gameReleaseNaDots = gameReleaseNa.substring(8, 10) + "." + gameReleaseNa.substring(5, 7) + "."
+ gameReleaseNa.substring(0, 4);
String gameReleaseAu = resultSet.getString("Game_Release_AU");
String gameReleaseAuDots;
if (gameReleaseAu != null) {
gameReleaseAuDots = gameReleaseAu.substring(8, 10) + "." + gameReleaseAu.substring(5, 7) + "."
+ gameReleaseAu.substring(0, 4);
} else {
gameReleaseAuDots = "Unknown";
}
int gameUsk = resultSet.getInt("Game_USK_Rating");
int gamePegi = resultSet.getInt("Game_PEGI_Rating");
String gameEsrb = resultSet.getString("Game_ESRB_Rating");
String gameCero = resultSet.getString("Game_CERO_Rating");
String gameAcb = resultSet.getString("Game_ACB_Rating");
String gamePlayers = resultSet.getString("Game_Players");
if (gamePegi != 0) {
result += id + ": " + gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu
+ ", " + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", "
+ gameReleaseEuDots + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", "
+ gameReleaseAuDots + ", " + gameUsk + ", " + gamePegi + ", " + gameEsrb + ", " + gameCero
+ ", " + gameAcb + ", " + gamePlayers + "\n";
} else {
result += id + ": " + gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu
+ ", " + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", "
+ gameReleaseEuDots + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", "
+ gameReleaseAuDots + ", " + gameUsk + ", Unknown, " + gameEsrb + ", " + gameCero + ", "
+ gameAcb + ", " + gamePlayers + "\n";
}
} }
statement.close(); statement.close();
@ -1110,9 +1117,12 @@ public class Games {
if (gameReleaseAu == null) { if (gameReleaseAu == null) {
} else { } else {
if (gameReleaseEu.substring(0, 4).equals(gameReleaseJp.substring(0, 4)) && gameReleaseJp.substring(0, 4).equals(gameReleaseNa.substring(0, 4))
&& gameReleaseEu.substring(0, 4).equals(gameReleaseNa.substring(0, 4)) && gameReleaseAu.substring(0, 4).equals(gameReleaseEu.substring(0, 4))
&& gameReleaseAu.substring(0, 4).equals(gameReleaseJp.substring(0, 4)) && gameReleaseAu.substring(0, 4).equals(gameReleaseNa.substring(0, 4))) {
if (gameReleaseEu.substring(0, 4).equals(gameReleaseJp.substring(0, 4))
&& gameReleaseJp.substring(0, 4).equals(gameReleaseNa.substring(0, 4))
&& gameReleaseEu.substring(0, 4).equals(gameReleaseNa.substring(0, 4))
&& gameReleaseAu.substring(0, 4).equals(gameReleaseEu.substring(0, 4))
&& gameReleaseAu.substring(0, 4).equals(gameReleaseJp.substring(0, 4))
&& gameReleaseAu.substring(0, 4).equals(gameReleaseNa.substring(0, 4))) {
result += gameName + ", "; result += gameName + ", ";
} }
} }
@ -1148,9 +1158,12 @@ public class Games {
if (gameReleaseAu == null) { if (gameReleaseAu == null) {
result += gameName + ", "; result += gameName + ", ";
} else { } else {
if (!gameReleaseEu.substring(0, 4).equals(gameReleaseJp.substring(0, 4)) || !gameReleaseJp.substring(0, 4).equals(gameReleaseNa.substring(0, 4))
|| !gameReleaseEu.substring(0, 4).equals(gameReleaseNa.substring(0, 4)) || !gameReleaseAu.substring(0, 4).equals(gameReleaseEu.substring(0, 4))
|| !gameReleaseAu.substring(0, 4).equals(gameReleaseJp.substring(0, 4)) || !gameReleaseAu.substring(0, 4).equals(gameReleaseNa.substring(0, 4))) {
if (!gameReleaseEu.substring(0, 4).equals(gameReleaseJp.substring(0, 4))
|| !gameReleaseJp.substring(0, 4).equals(gameReleaseNa.substring(0, 4))
|| !gameReleaseEu.substring(0, 4).equals(gameReleaseNa.substring(0, 4))
|| !gameReleaseAu.substring(0, 4).equals(gameReleaseEu.substring(0, 4))
|| !gameReleaseAu.substring(0, 4).equals(gameReleaseJp.substring(0, 4))
|| !gameReleaseAu.substring(0, 4).equals(gameReleaseNa.substring(0, 4))) {
result += gameName + ", "; result += gameName + ", ";
} }
} }
@ -1180,7 +1193,8 @@ public class Games {
String gameName = resultSet.getString("Game_Name"); String gameName = resultSet.getString("Game_Name");
String gamePlayers = resultSet.getString("Game_Players"); String gamePlayers = resultSet.getString("Game_Players");
if (gamePlayers.equals("1") || gamePlayers.equals("1-2") || gamePlayers.equals("1-4") || gamePlayers.equals("1-8")) {
if (gamePlayers.equals("1") || gamePlayers.equals("1-2") || gamePlayers.equals("1-4")
|| gamePlayers.equals("1-8")) {
result += gameName + ", "; result += gameName + ", ";
} }

Loading…
Cancel
Save