Package tetris.model

Class Scoring

java.lang.Object
tetris.model.Scoring

public class Scoring extends Object
The class Score implements the scoring of the Tetris game.
Version:
2.1
Author:
Stephan Fischli
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private 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
    Constructor
    Description
    Constructs a scoring and reads the high score file.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the high score of the game.
    int
    Gets the current level of the game.
    int
    Gets the current score of the game.
    private void
    Loads the high score from the high score file.
    void
    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.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SCORE_REWARDS

      private static final int[] SCORE_REWARDS
      The score rewards for the removal of full rows.
    • ROWS_PER_LEVEL

      private static final int ROWS_PER_LEVEL
      The number of rows needed to enter the next level.
      See Also:
    • HIGH_SCORE_FILE

      private static final String HIGH_SCORE_FILE
      The name of the high score file.
      See Also:
    • removedRows

      private int removedRows
      The total number of removed rows.
    • score

      private int score
      The current score of the game.
    • highScore

      private int highScore
      The 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.