Package model

Class Scoreboard

java.lang.Object
model.Scoreboard

public class Scoreboard extends Object
Scoreboard class for the game Contains list of Score-objects and methods for adding and retrieving scores Also contains methods for retrieving scores from the database
  • Field Details

    • leaderboarddao

      private static final ILeaderboardDAO leaderboarddao
      DAO class for database connection
    • scores

      private final ArrayList<Score> scores
      List of scores
  • Constructor Details

    • Scoreboard

      public Scoreboard()
      Constructor for Scoreboard
    • Scoreboard

      public Scoreboard(ArrayList<Leaderboard> leaderboards)
      Constructor for Scoreboard
      Parameters:
      leaderboards - list of Leaderboard-objects
  • Method Details

    • addScore

      public void addScore(Double time, int points, ModeType difficulty, boolean saveToRemote)
      Adds a score to the scoreboard
      Parameters:
      time - time in seconds
      points - points
      difficulty - difficulty
    • getScores

      public ArrayList<Score> getScores()
      Returns the list of scores
      Returns:
      list of scores
    • deleteScore

      public void deleteScore(Long scoreid)
      Deletes a score from the scoreboard
      Parameters:
      scoreid - id of the score to be deleted
    • fetchWorldScores

      public void fetchWorldScores(ModeType difficulty)
      Fetch global scores of select difficulty, sorted by points (desc) and then time (asc)
      Parameters:
      difficulty - difficulty of the scores
    • fetchUserScores

      public void fetchUserScores(Long userid, ModeType difficulty)
      Fetch personal scores of select difficulty, sorted by time
      Parameters:
      userid - id of the user
      difficulty - difficulty level of the scores
    • toString

      public String toString()
      tostring method for Scoreboard
      Overrides:
      toString in class Object
      Returns:
      string representation of the scoreboard