Class Level


  • public class Level
    extends Object
    The Level class contains game logic used in conjunction with the GameViewModel.
    • Constructor Detail

      • Level

        public Level​(Note tonic,
                     Mode mode)
        The constructor initializes the tonic and mode of the scale.
        Parameters:
        tonic - The scale's tonic.
        mode - The scale's mode.
    • Method Detail

      • getScore

        public int getScore()
        Returns the current score in the level.
        Returns:
        The current score.
      • setScore

        public void setScore​(int points)
        Sets the score for the level by adding the new points. Also sets levelWon to true if the minimum score has been reached.
        Parameters:
        points - The points to be added to the current score.
      • getHearts

        public int getHearts()
        Returns the current number of lives/hearts left.
        Returns:
        The hearts left.
      • setHearts

        public void setHearts​(boolean heartAdded)
        Increments or decrements the number of hearts left. Also sets levelWon to false if there are no hearts left.
        Parameters:
        heartAdded - True if a heart has been added, false if it has been removed.
      • getTonic

        public Note getTonic()
        Returns the tonic of the scale.
        Returns:
        The tonic of the scale.
      • getMode

        public Mode getMode()
        Returns the mode of the scale.
        Returns:
        The mode of the scale.
      • getLevelWon

        public Boolean getLevelWon()
        Returns true if the level has been won and false if it has been lost. If the level is in progress, this will return null.
        Returns:
        Whether the level has been won, lost, or is in progress.