Class HighScoresList

java.lang.Object
  |
  +--HighScoresList

public class HighScoresList
extends java.lang.Object

The HighScoresList class is a list of the top 15 scores achieved during the play of Sokoban.


Constructor Summary
HighScoresList(boolean junit)
          Constructor - initializes the scores vector.
HighScoresList(Game game)
          Constructor - initializes the scores vector.
 
Method Summary
 void addHighScore(HighScore score)
          The addScores method allows the user to add scores to the high scores list.
 void clearHighScores()
          The clearHighScores method allows the user to clear the current list of high scores.
 void loadHighScores()
          The loadHighScores method allows the user to load the scores from a file.
protected  HighScore[] toArray()
          Returns the High Scores List as an array of HighScores.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HighScoresList

public HighScoresList(Game game)
Constructor - initializes the scores vector.

HighScoresList

public HighScoresList(boolean junit)
Constructor - initializes the scores vector.
Method Detail

loadHighScores

public void loadHighScores()
The loadHighScores method allows the user to load the scores from a file.


Precondition: high scores file exists
Postcondition:The list of high scores is loaded to be viewed by the user


addHighScore

public void addHighScore(HighScore score)
The addScores method allows the user to add scores to the high scores list. It finds where the score belongs and then inserts the score at the appropriate place. If there are more than 15 users on the high scores list then the method removes the last score from the list.
Parameters:
score - a HighScore class with name and score to be added to the high scores list


Precondition:Checks to see if the file have space for name and score entry
Postcondition:The added name and score will be saved in the high scores list.


clearHighScores

public void clearHighScores()
The clearHighScores method allows the user to clear the current list of high scores.
Precondition:None
Postcondition:high scores list is empty

toArray

protected HighScore[] toArray()
Returns the High Scores List as an array of HighScores.