|
|
@ -8,10 +8,12 @@ import java.sql.Statement; |
|
|
|
|
|
|
|
public class Games { |
|
|
|
private String databaseURL = "jdbc:ucanaccess://GamesDB.accdb"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Checks if the connection to the database can be established |
|
|
|
* @return Returns true if it connects successfully and false if the connection fails. |
|
|
|
* |
|
|
|
* @return Returns true if it connects successfully and false if the connection |
|
|
|
* fails. |
|
|
|
*/ |
|
|
|
public boolean checkConnection() { |
|
|
|
try { |
|
|
@ -24,9 +26,11 @@ public class Games { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Prints the whole table for those, who cannot access the Database for some reason. |
|
|
|
* Prints the whole table for those, who cannot access the Database for some |
|
|
|
* reason. |
|
|
|
* |
|
|
|
* @return Returns a String of the whole table. |
|
|
|
*/ |
|
|
|
public String printTable() { |
|
|
@ -101,7 +105,12 @@ public class Games { |
|
|
|
// The substring removes the last New line in the String. |
|
|
|
return result.substring(0, result.length() - 1); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Prints out all game names from the table. |
|
|
|
* |
|
|
|
* @return Returns a String with the game names |
|
|
|
*/ |
|
|
|
public String checkGames() { |
|
|
|
String result = ""; |
|
|
|
String query = "SELECT Game_Name FROM Games"; |
|
|
@ -128,6 +137,11 @@ public class Games { |
|
|
|
return result.substring(0, result.length() - 2); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Prints out all of the consoles which are represented in the table. |
|
|
|
* |
|
|
|
* @return Returns a String with the consoles. |
|
|
|
*/ |
|
|
|
public String checkConsoles() { |
|
|
|
String result = ""; |
|
|
|
String query = "SELECT Game_Console FROM Games"; |
|
|
@ -458,6 +472,11 @@ public class Games { |
|
|
|
return result.substring(0, result.length() - 2); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Prints out all of the games which are on a PlayStation console. |
|
|
|
* |
|
|
|
* @return Returns a String with the games from a PlayStation console. |
|
|
|
*/ |
|
|
|
public String checkConsolePlayStation() { |
|
|
|
String result = ""; |
|
|
|
String query = "SELECT Game_Name, Game_Console FROM Games"; |
|
|
@ -490,6 +509,11 @@ public class Games { |
|
|
|
return result.substring(0, result.length() - 2); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Prints out all of the games which are on a Nintendo console. |
|
|
|
* |
|
|
|
* @return Returns a String with the games from a Nintendo console. |
|
|
|
*/ |
|
|
|
public String checkConsoleNintendo() { |
|
|
|
String result = ""; |
|
|
|
String query = "SELECT Game_Name, Game_Console FROM Games"; |
|
|
@ -522,6 +546,11 @@ public class Games { |
|
|
|
return result.substring(0, result.length() - 2); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Prints out all of the games which are on a Xbox console. |
|
|
|
* |
|
|
|
* @return Returns a String with the games from a Xbox console. |
|
|
|
*/ |
|
|
|
public String checkConsoleXbox() { |
|
|
|
String result = ""; |
|
|
|
String query = "SELECT Game_Name, Game_Console FROM Games"; |
|
|
@ -554,6 +583,11 @@ public class Games { |
|
|
|
return result.substring(0, result.length() - 2); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Prints out all of the games which are multiplatform. |
|
|
|
* |
|
|
|
* @return Returns a String with the multiplatform games . |
|
|
|
*/ |
|
|
|
public String checkConsoleMultiplatform() { |
|
|
|
String result = ""; |
|
|
|
String query = "SELECT Game_Name, Game_Console FROM Games"; |
|
|
@ -586,6 +620,11 @@ public class Games { |
|
|
|
return result.substring(0, result.length() - 2); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Prints out all of the games which are on a Nintendo Switch. |
|
|
|
* |
|
|
|
* @return Returns a String with the games from a Nintendo Switch. |
|
|
|
*/ |
|
|
|
public String checkConsoleNintendoSwitch() { |
|
|
|
String result = ""; |
|
|
|
String query = "SELECT Game_Name, Game_Console FROM Games"; |
|
|
|