Class Level

  • All Implemented Interfaces:
    java.lang.Runnable

    public class Level
    extends java.lang.Thread
    This class contains information about the running game
    Author:
    dmlux, I. Schumacher, modified by 175
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Ball ball
      The ball of the level
      private boolean ballWasStarted
      Flag that shows if the ball was started
      private Game game
      The game to which the level belongs
      private int levelnr
      The number of the level
      private int score
      The score of the level
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      Level​(Game game, int levelnr, int score)
      The constructor creates a new level object and needs the current game object, the number of the level to be created and the current score
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean ballWasStarted()
      Returns if the ball is moving or stopped
      Ball getBall()
      The getter for the ball object
      private void loadLevelData​(int levelnr)
      Loads the information for the level from a json-file located in the folder /res of the project
      void run()
      The method of the level thread
      void startBall()
      Sets ballWasStarted to true, the ball is moving
      void stopBall()
      Sets ballWasStarted to false, the ball is stopped
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • game

        private Game game
        The game to which the level belongs
      • levelnr

        private int levelnr
        The number of the level
      • score

        private int score
        The score of the level
      • ball

        private Ball ball
        The ball of the level
      • ballWasStarted

        private boolean ballWasStarted
        Flag that shows if the ball was started
    • Constructor Detail

      • Level

        public Level​(Game game,
                     int levelnr,
                     int score)
        The constructor creates a new level object and needs the current game object, the number of the level to be created and the current score
        Parameters:
        game - The game object
        levelnr - The number of the new level object
        score - The score
    • Method Detail

      • getBall

        public Ball getBall()
        The getter for the ball object
        Returns:
        ball The ball of the level
      • startBall

        public void startBall()
        Sets ballWasStarted to true, the ball is moving
      • stopBall

        public void stopBall()
        Sets ballWasStarted to false, the ball is stopped
      • ballWasStarted

        public boolean ballWasStarted()
        Returns if the ball is moving or stopped
        Returns:
        ballWasStarted True: the ball is moving; false: the ball is stopped
      • run

        public void run()
        The method of the level thread
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • loadLevelData

        private void loadLevelData​(int levelnr)
        Loads the information for the level from a json-file located in the folder /res of the project
        Parameters:
        levelnr - The number X for the LevelX.json file