Class Ball

  • All Implemented Interfaces:
    IBall

    public class Ball
    extends java.lang.Object
    implements IBall
    This class contains the information about the balls characteristics and behavior
    Author:
    iSchumacher, modified by 175
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Vector2D direction
      The balls direction
      private Position position
      The balls position on the playground
    • Constructor Summary

      Constructors 
      Constructor Description
      Ball()
      The constructor of a ball The balls position and direction are initialized here.
    • Field Detail

      • position

        private Position position
        The balls position on the playground
      • direction

        private Vector2D direction
        The balls direction
    • Constructor Detail

      • Ball

        public Ball()
        The constructor of a ball The balls position and direction are initialized here.
    • Method Detail

      • getPosition

        public Position getPosition()
        The getter for the balls position
        Specified by:
        getPosition in interface IBall
        Returns:
        position The balls current position
      • getDirection

        public Vector2D getDirection()
        The getter for the balls direction
        Specified by:
        getDirection in interface IBall
        Returns:
        direction The balls current direction
      • updatePosition

        public void updatePosition()
        updates ball position
        Specified by:
        updatePosition in interface IBall
      • reactOnBorder

        public void reactOnBorder()
        Ball reacts to contact with the borders
        Specified by:
        reactOnBorder in interface IBall