Class Paddle

  • All Implemented Interfaces:
    IPaddle

    public class Paddle
    extends java.lang.Object
    implements IPaddle
    This class contains the information about the paddles characteristics and behavior
    Author:
    Gruppe 175: Moritz Henseleit, Ruben Meyer
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Color color
      The paddles color
      private int direction
      The paddles direction on the playground only -1,0,+1 are valid values
      private int height  
      private Position position
      The paddles position on the playground
      private int width
      The paddles sizing
    • Constructor Summary

      Constructors 
      Constructor Description
      Paddle​(Position position)
      The constructor of a paddle
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Color getColor()
      The getter for the paddles color
      int getDirection()
      The getter for the paddles direction
      int getHeight()
      The getter for the paddles height
      Position getPosition()
      The getter for the paddles position
      int getWidth()
      The getter for the paddles width
      void setColor​(java.awt.Color color)
      The setter for the paddles color
      void setDirection​(int direction)
      The setter for the paddles direction
      void setHeight​(int height)
      The setter for the paddles height
      void setPosition​(Position position)
      The setter for the paddles position
      void setWidth​(int width)
      The setter for the paddles width
      void updatePosition​(Ball ball)
      Updates paddles position based on balls position
      • Methods inherited from class java.lang.Object

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

      • position

        private Position position
        The paddles position on the playground
      • direction

        private int direction
        The paddles direction on the playground only -1,0,+1 are valid values
      • width

        private int width
        The paddles sizing
      • height

        private int height
      • color

        private java.awt.Color color
        The paddles color
    • Constructor Detail

      • Paddle

        public Paddle​(Position position)
        The constructor of a paddle
        Parameters:
        position - paddles initial position
    • Method Detail

      • getPosition

        public Position getPosition()
        The getter for the paddles position
        Specified by:
        getPosition in interface IPaddle
        Returns:
        position The paddles current position
      • setPosition

        public void setPosition​(Position position)
        The setter for the paddles position
        Specified by:
        setPosition in interface IPaddle
        Parameters:
        position - The paddles new position
      • getColor

        public java.awt.Color getColor()
        The getter for the paddles color
        Specified by:
        getColor in interface IPaddle
        Returns:
        color The paddles current color
      • setColor

        public void setColor​(java.awt.Color color)
        The setter for the paddles color
        Specified by:
        setColor in interface IPaddle
        Parameters:
        color - The paddles new color
      • getWidth

        public int getWidth()
        The getter for the paddles width
        Specified by:
        getWidth in interface IPaddle
        Returns:
        width The paddles current width
      • setWidth

        public void setWidth​(int width)
        The setter for the paddles width
        Specified by:
        setWidth in interface IPaddle
        Parameters:
        width - The paddles new width
      • getHeight

        public int getHeight()
        The getter for the paddles height
        Specified by:
        getHeight in interface IPaddle
        Returns:
        height The paddles current height
      • setHeight

        public void setHeight​(int height)
        The setter for the paddles height
        Specified by:
        setHeight in interface IPaddle
        Parameters:
        height - The paddles new height
      • getDirection

        public int getDirection()
        The getter for the paddles direction
        Specified by:
        getDirection in interface IPaddle
        Returns:
        direction The paddles current direction
      • setDirection

        public void setDirection​(int direction)
        The setter for the paddles direction
        Specified by:
        setDirection in interface IPaddle
        Parameters:
        direction - The paddles new direction
      • updatePosition

        public void updatePosition​(Ball ball)
        Updates paddles position based on balls position
        Specified by:
        updatePosition in interface IPaddle
        Parameters:
        ball - The ball