example.wormgame
Class WormScore

java.lang.Object
  extended by example.wormgame.WormScore

public class WormScore
extends java.lang.Object

The WormScore keeps track of the high scores for each of the worm levels. All access to the scores occur through static methods. There can never be a WormScore object. We cache the scores and names for quick access during game play. The calling application must first call openHighScores() to open the score database. Finally, a closeHighScores() must be called to release system resources.


Method Summary
(package private) static void closeHighScores()
          Close the high score file
(package private) static short getHighScore(int level)
          Return the high score for a given level.
(package private) static java.lang.String getHighScoreName(int level)
          Return the high score name for a given level.
(package private) static void openHighScores()
          Open the high score storage file.
(package private) static void setHighScore(int level, int newScore, java.lang.String name)
          Save high score for posterity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

openHighScores

static void openHighScores()
Open the high score storage file. If the file doesn't exist, initialize all high scores to 0.


closeHighScores

static void closeHighScores()
Close the high score file


setHighScore

static void setHighScore(int level,
                         int newScore,
                         java.lang.String name)
Save high score for posterity.

Parameters:
level - current game level
newScore - current game score to be recorded
name - current user name to be recorded

getHighScore

static short getHighScore(int level)
Return the high score for a given level.

Parameters:
level - current level for high score check
Returns:
numeric value for highest score at the requested level

getHighScoreName

static java.lang.String getHighScoreName(int level)
Return the high score name for a given level.

Parameters:
level - current level for high score check
Returns:
name for highest score at the requested level