java.lang.Object
edu.ntnu.idatt1002.k01g08.fta.objects.events.GameEvent
edu.ntnu.idatt1002.k01g08.fta.objects.events.Goal

public class Goal extends GameEvent
Class representing a goal scored in a match. This is a specific game event and is therefore represented as being a subclass of the abstract class 'GameEvent'. Additional information associated with a Goal is 'assistingPlayer', another player, which is the player who assisted the goal. This player does not have to be specified as some Goals happen without any given player assisting the player who scores To circumvent this, the class has two constructors, with and without a parameter for assistingPlayer.
  • Constructor Details

    • Goal

      public Goal(Player goalScorer, Team team, String timeStamp, Player assistingPlayer) throws IllegalArgumentException
      First constructor to instantiate specific Goals
      Parameters:
      goalScorer - is the player scoring the goal
      team - is the team scoring the goal
      timeStamp - is a String with the time of the goal
      assistingPlayer - is the player assisting the goal
      Throws:
      IllegalArgumentException - specified in the GameEvent class
    • Goal

      public Goal(Player goalScorer, Team team, String timeStamp) throws IllegalArgumentException
      Second constructor to instantiate a Goal without an assistingPlayer
      Parameters:
      goalScorer - is the player scoring the goal
      team - is a Team
      timeStamp - is String
      Throws:
      IllegalArgumentException - specified in the GameEvent class
  • Method Details

    • getAssistingPlayer

      public Player getAssistingPlayer()
      Accessor method to get the assisting player of this goal
      Returns:
      Player assistingPlayer
    • getEvent

      public String getEvent()
      GetEvent method to get a full description of the Goal event
      Specified by:
      getEvent in class GameEvent
      Returns:
      String goal description
    • toString

      public String toString()
      Description copied from class: GameEvent
      Returns a string representation of a GameEvent object
      Overrides:
      toString in class GameEvent
      Returns:
      a string representing an object of the class GameEvent.