Skip to content

DataBase

ohadcohen1111 edited this page Jan 23, 2020 · 2 revisions

Object variables:

  • public static final String jdbcUrl = "jdbc:mysql://db-mysql-ams3-67328-do-user-4468260-0.db.ondigitalocean.com:25060/oop?useUnicode=yes&characterEncoding=UTF-8&useSSL=false" - data base url.

  • public static final String jdbcUser = "student" - data base user.

  • public static final String jdbcUserPassword = "OOP2020student" - data base password.

  • private static final int MYID = 209046879 - my ID.

  • private static Connection connection = null - create connection with the server.

  • private static HashMap<Integer, Integer> scoreCompOthers = new HashMap<Integer, Integer>() - the top results of others.

  • private static String[] allScoresPerLevel = new String[10] - then best 10 scores per specific level.

  • private static int[] scores = { 125, 436, 0, 713, 0, 570, 0, 0, 0, 480, 0, 1050, 0, 310, 0, 0, 235, 0, 0, 250, 200, 0, 0, 1000 } - the result that needs to be achieved to go through a level.

  • private static int[] moves = { 290, 580, 0, 580, 0, 500, 0, 0, 0, 580, 0, 580, 0, 580, 0, 0, 290, 0, 0, 580, 290, 0, 0, 1140 } - the maximum number of moves allowed for a stage.

Constructor

  • public DataBase() - empty constructor.

Methods:

  • public static int getMyLevel(int id) - return current level for id.

  • public static void allUsers(int level) - insert the best results of others to the HashMap.

  • public String[] scoreTable(int level) - return the top 10 to specific level.

  • public static int getMyPlace(int level) - return my place per specific level.

  • public static int bestScore(int level) - return my best score to specific level.

  • public String[] getAllScoresPerLevel() - return getAllScoresPerLevel array.

  • public int[] getMoves() - return moves array.

Clone this wiki locally