Class Level

  • All Implemented Interfaces:
    ILevel, java.lang.Runnable

    public class Level
    extends java.lang.Thread
    implements ILevel
    This class contains information about the running game
    Author:
    dmlux, I. Schumacher; modified by Gruppe 175 (Moritz Henseleit, Ruben Meyer)
    • 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 Paddle paddleBottom
      The paddles of the level
      private Paddle paddleTop
      The paddles 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
      Paddle getPaddleBottom()
      The getter for the bottom paddle object
      Paddle getPaddleTop()
      The getter for the top paddle 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
      • paddleTop

        private Paddle paddleTop
        The paddles of the level
      • paddleBottom

        private Paddle paddleBottom
        The paddles of the level
    • 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
        Specified by:
        getBall in interface ILevel
        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
      • getPaddleTop

        public Paddle getPaddleTop()
        The getter for the top paddle object
        Specified by:
        getPaddleTop in interface ILevel
        Returns:
        paddleTop The top paddle of the level
      • getPaddleBottom

        public Paddle getPaddleBottom()
        The getter for the bottom paddle object
        Specified by:
        getPaddleBottom in interface ILevel
        Returns:
        paddleBottom The bottom paddle of the level