Package tetris.model
Class Scoring
java.lang.Object
tetris.model.Scoring
The class Score implements the scoring of the Tetris game.
- Version:
- 2.1
- Author:
- Stephan Fischli
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The name of the high score file.private int
The high score of the game.private int
The total number of removed rows.private static final int
The number of rows needed to enter the next level.private int
The current score of the game.private static final int[]
The score rewards for the removal of full rows. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the high score of the game.int
getLevel()
Gets the current level of the game.int
getScore()
Gets the current score of the game.private void
Loads the high score from the high score file.void
reset()
Resets the level and the score of the game.private void
Saves the high score to the high score file.void
Updates the high score according to the current score.void
updateScore
(int numRows) Updates the score according to the number of removed rows.
-
Field Details
-
SCORE_REWARDS
private static final int[] SCORE_REWARDSThe score rewards for the removal of full rows. -
ROWS_PER_LEVEL
private static final int ROWS_PER_LEVELThe number of rows needed to enter the next level.- See Also:
-
HIGH_SCORE_FILE
The name of the high score file.- See Also:
-
removedRows
private int removedRowsThe total number of removed rows. -
score
private int scoreThe current score of the game. -
highScore
private int highScoreThe high score of the game.
-
-
Constructor Details
-
Scoring
public Scoring()Constructs a scoring and reads the high score file.
-
-
Method Details
-
getLevel
public int getLevel()Gets the current level of the game.- Returns:
- the current level of the game
-
getScore
public int getScore()Gets the current score of the game.- Returns:
- the current score of the game
-
getHighScore
public int getHighScore()Gets the high score of the game.- Returns:
- the high score of the game
-
updateScore
public void updateScore(int numRows) Updates the score according to the number of removed rows.- Parameters:
numRows
- the number of removed rows
-
updateHighScore
public void updateHighScore()Updates the high score according to the current score. -
reset
public void reset()Resets the level and the score of the game. -
loadHighScore
private void loadHighScore()Loads the high score from the high score file. -
saveHighScore
private void saveHighScore()Saves the high score to the high score file.
-