Package database.dao

Class LeaderboardDAO

java.lang.Object
database.dao.LeaderboardDAO
All Implemented Interfaces:
ILeaderboardDAO

public class LeaderboardDAO extends Object implements ILeaderboardDAO
LeaderboardDAO class for the game Contains methods for saving and retrieving scores from the database
  • Constructor Details

    • LeaderboardDAO

      public LeaderboardDAO()
  • Method Details

    • saveScore

      public boolean saveScore(Leaderboard lb)
      Saves a score to the database
      Specified by:
      saveScore in interface ILeaderboardDAO
      Parameters:
      lb - Leaderboard-object to be saved
      Returns:
      true if successful, false if not
    • getAccountScores

      public ArrayList<Leaderboard> getAccountScores(Long accountid)
      selects top 100 scores sorted by points, then time
      Specified by:
      getAccountScores in interface ILeaderboardDAO
      Parameters:
      accountid - account id
      Returns:
      ArrayList of Leaderboard-objects
    • getAccountScoresByDifficulty

      public ArrayList<Leaderboard> getAccountScoresByDifficulty(Long accountid, ModeType difficulty)
      selects top 100 scores of select account and difficulty
      Specified by:
      getAccountScoresByDifficulty in interface ILeaderboardDAO
      Parameters:
      accountid - account id
      difficulty - difficulty
      Returns:
      ArrayList of Leaderboard-objects
    • readWorldScores

      public ArrayList<Leaderboard> readWorldScores(ModeType difficulty)
      selects top 100 scores of select difficulty
      Specified by:
      readWorldScores in interface ILeaderboardDAO
      Returns:
      ArrayList of Leaderboard-objects
    • deleteScore

      public boolean deleteScore(Long scoreid)
      deletes a score by id
      Specified by:
      deleteScore in interface ILeaderboardDAO
      Parameters:
      scoreid - score id
      Returns:
      true if successful
    • deleteAllScores

      public void deleteAllScores(Long accountid)
      deletes all scores of select account
      Specified by:
      deleteAllScores in interface ILeaderboardDAO
      Parameters:
      accountid - account id