edu.uiuc.cs397rhc.game
Class ScoreEvent

java.lang.Object
  extended by java.util.EventObject
      extended by edu.uiuc.cs397rhc.game.GameEvent
          extended by edu.uiuc.cs397rhc.game.ScoreEvent
All Implemented Interfaces:
java.io.Serializable

public class ScoreEvent
extends GameEvent

Fired when the score is updated for any reason. This class provides the both the list of scores and the team that scored, but the team is not always expected to be specified.

Author:
Steven N. Severinghaus
See Also:
GameUtils, Serialized Form

Field Summary
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
ScoreEvent(java.lang.Object source, java.util.EnumMap<GameUtils.Team,java.lang.Integer> scores)
          Constructs a score event with the specified scores, coming from the specified source.
ScoreEvent(java.lang.Object source, GameUtils.Team team, java.util.EnumMap<GameUtils.Team,java.lang.Integer> scores)
          Constructs a score event indicating that the specified team has scored.
 
Method Summary
 java.util.EnumMap<GameUtils.Team,java.lang.Integer> getScores()
          Returns the current scores for all teams.
 GameUtils.Team getTeam()
          Returns the team that scored, if known.
 void setScores(java.util.EnumMap<GameUtils.Team,java.lang.Integer> scores)
          Sets the list of scores for all teams.
 void setTeam(GameUtils.Team team)
          Sets the team that has scored.
 java.lang.String toString()
          Returns a string representation of this score event.
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScoreEvent

public ScoreEvent(java.lang.Object source,
                  java.util.EnumMap<GameUtils.Team,java.lang.Integer> scores)
Constructs a score event with the specified scores, coming from the specified source. No attempt is made to figure out the team based on previous scores or anything cute like that.

Parameters:
source - the source of this event
scores - the current scores for all teams

ScoreEvent

public ScoreEvent(java.lang.Object source,
                  GameUtils.Team team,
                  java.util.EnumMap<GameUtils.Team,java.lang.Integer> scores)
Constructs a score event indicating that the specified team has scored. The new score and the source of the event are also specified.

Parameters:
source - the source of this event
team - the team that has scored
scores - the current scores for all teams
Method Detail

getTeam

public GameUtils.Team getTeam()
Returns the team that scored, if known.

Returns:
the team that scored or null if the team is not known

getScores

public java.util.EnumMap<GameUtils.Team,java.lang.Integer> getScores()
Returns the current scores for all teams.

Returns:
the current scores for all teams

setTeam

public void setTeam(GameUtils.Team team)
Sets the team that has scored.

Parameters:
team - the team that has scored

setScores

public void setScores(java.util.EnumMap<GameUtils.Team,java.lang.Integer> scores)
Sets the list of scores for all teams.

Parameters:
scores - the list of scores for all teams

toString

public java.lang.String toString()
Returns a string representation of this score event. The format of the string is ScoreEvent[team=...;scores={...}].

Overrides:
toString in class java.util.EventObject
Returns:
a string representation of this score event