|
@ -8,10 +8,12 @@ import java.sql.Statement; |
|
|
|
|
|
|
|
|
public class Games { |
|
|
public class Games { |
|
|
private String databaseURL = "jdbc:ucanaccess://GamesDB.accdb"; |
|
|
private String databaseURL = "jdbc:ucanaccess://GamesDB.accdb"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Checks if the connection to the database can be established |
|
|
* 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() { |
|
|
public boolean checkConnection() { |
|
|
try { |
|
|
try { |
|
@ -24,9 +26,11 @@ public class Games { |
|
|
return false; |
|
|
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. |
|
|
* @return Returns a String of the whole table. |
|
|
*/ |
|
|
*/ |
|
|
public String printTable() { |
|
|
public String printTable() { |
|
@ -101,7 +105,12 @@ public class Games { |
|
|
// The substring removes the last New line in the String. |
|
|
// The substring removes the last New line in the String. |
|
|
return result.substring(0, result.length() - 1); |
|
|
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() { |
|
|
public String checkGames() { |
|
|
String result = ""; |
|
|
String result = ""; |
|
|
String query = "SELECT Game_Name FROM Games"; |
|
|
String query = "SELECT Game_Name FROM Games"; |
|
@ -128,6 +137,11 @@ public class Games { |
|
|
return result.substring(0, result.length() - 2); |
|
|
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() { |
|
|
public String checkConsoles() { |
|
|
String result = ""; |
|
|
String result = ""; |
|
|
String query = "SELECT Game_Console FROM Games"; |
|
|
String query = "SELECT Game_Console FROM Games"; |
|
@ -458,6 +472,11 @@ public class Games { |
|
|
return result.substring(0, result.length() - 2); |
|
|
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() { |
|
|
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"; |
|
@ -490,6 +509,11 @@ public class Games { |
|
|
return result.substring(0, result.length() - 2); |
|
|
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() { |
|
|
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"; |
|
@ -522,6 +546,11 @@ public class Games { |
|
|
return result.substring(0, result.length() - 2); |
|
|
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() { |
|
|
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"; |
|
@ -554,6 +583,11 @@ public class Games { |
|
|
return result.substring(0, result.length() - 2); |
|
|
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() { |
|
|
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"; |
|
@ -586,6 +620,11 @@ public class Games { |
|
|
return result.substring(0, result.length() - 2); |
|
|
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() { |
|
|
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"; |
|
|