dbConnector - VadimKachevski/OOP_Ex3 GitHub Wiki

This class was built in order to retrieve the data from the MySQL data base.

This class is represented by 3 Strings that are final and through he them we will get access to the relevant database.

public static final String jdbcUrl= represents the URL of the data base.

public static final String jdbcUser=represents the user name.

public static final String jdbcUserPassword represents the password.

Methods of this class

public static Object[][] GetData() – this class returns a matrix which represents the data as follows;

  • data[][0] = rs.getInt("levelID") – represents the Id of the level.

  • data[][1] = rs.getInt("moves") – represents amount of moves.

  • data[][2] = rs.getDate("time") – represents the time.

  • data[][3] = rs.getDouble("score") – represents the score.

  • data[][4] = rs.getInt("UserID") – represents the id of the user.

  • Data[][5] = rs.getInt("logID") – represents the id which the player got.

public static int[] getNumbergames(int id) – by a given id this method returns an array amount of games we have played and the maximum level reached.

public static double[][] bestResult(int id) – by a given id this method returns a matrix [12][4] which the rows represents the levels and the columns represents the score to beat, the score that the user achieved, the maximum moves, and the moves the user reached.

public static int[] findRank(double[][] helpArr) – by a given a matrix with the information about the moves and scores of the user this method will return an array filled with the rank of each level in relation towards the rest of the participants in this project. Each position in the array represents the level. In this method we used a hashtable of a hsastable to help us keep the data of the users. The key of the first map represents the level and the key of the second map representys the user ID.

private static double amountMovesOther(int i) – By a given case number this method helps us translate the case number to its max moves allowed for that specific case and returns the amount of moves.

private static int amountScore(int index) - By a given case number this method helps us translate the case number to its minimum score allowed for that specific case and returns the score.

private static int amountMoves(int index) - By a given level this method helps us translate the level to its max moves allowed for that specific level and returns the amount of moves.

private static int whichStageReverse(int index) - By a given level this method helps us translate the level to its case number which represents the given level and returns it.

private static int whichStage(int index) - By a given a case number this method helps us translate the case number to its level number which represents the given case number and returns it.