Package football2 :: Module match :: Class Match
[hide private]
[frames] | no frames]

Class Match

object --+
         |
        Match

The class Match represents match results in a football match statistics program. A match is played between teams from two clubs: a home club and an away club. Goals scored by players from either team can be added to the match object with the method add_goal. The class is expected to be used so that a match object is initially creates as a real-life match starts and goals are added incrementally as the match progresses.

Instance Methods [hide private]
 
__init__(self, home_club, away_club)
Constructs a match between teams of the given clubs, with no goals scored (yet).
club object
get_home_club(self)
Returns the club who hosts the match.
club object
get_away_club(self)
Returns the club who is visiting the home club to play the match.
 
add_goal(self, scorer)
Records a goal as having been scored in the match.
int
get_home_goals(self)
Returns the number of goals scored by the home team.
int
get_away_goals(self)
Returns the number of goals scored by the away team.
int
get_total_goals(self)
Returns the total number of goals scored by the two teams.
int
get_goal_difference(self)
Returns the goal difference of the match as an absolute value.
boolean
is_home_win(self)
Returns a boolean value indicating if the home team won.
boolean
is_away_win(self)
Returns a boolean value indicating if the away team won.
boolean
is_draw(self)
Returns a boolean value indicating if the match ended in a draw.
club object
get_winner(self)
Returns the club whose team won the match (or is about to win it, assuming the current result stands).
player object
get_winning_goal_scorer(self)
Returns the player who scored the so-called "winning goal".
bolean
is_higher_scoring_than(self, another_match)
Returns a boolean value indicating if the match had a higher number of goals than another given match.
string
get_location(self)
Returns the name of the stadium at which the game is played.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, home_club, away_club)
(Constructor)

 

Constructs a match between teams of the given clubs, with no goals scored (yet).

Parameters:
  • home_club (club object) - the club whose team plays at home in the match
  • away_club (club object) - the club whose team plays away in the match
Overrides: object.__init__

get_home_club(self)

 

Returns the club who hosts the match.

Returns: club object
home club

get_away_club(self)

 

Returns the club who is visiting the home club to play the match.

Returns: club object
away club

add_goal(self, scorer)

 

Records a goal as having been scored in the match. Whether the goal is a home goal or an away goal is determined by checking the employer of the given goal scorer. (If the given scorer is not employed by either club, the method does nothing.)

Parameters:
  • scorer (player object) - the player who scored the goal

get_home_goals(self)

 

Returns the number of goals scored by the home team.

Returns: int
home team's goal count

get_away_goals(self)

 

Returns the number of goals scored by the away team.

Returns: int
away team's goal count

get_total_goals(self)

 

Returns the total number of goals scored by the two teams.

Returns: int
total goal count

get_goal_difference(self)

 

Returns the goal difference of the match as an absolute value. (i.e. 2 - 3 returns 1) A tied match has a goal difference of zero.

Returns: int
goal difference

is_home_win(self)

 

Returns a boolean value indicating if the home team won.

Returns: boolean
True if the home team won, False otherwise

is_away_win(self)

 

Returns a boolean value indicating if the away team won.

Returns: boolean
True if the away team won, False otherwise

is_draw(self)

 

Returns a boolean value indicating if the match ended in a draw.

Returns: boolean
True if the neither team won, False otherwise

get_winner(self)

 

Returns the club whose team won the match (or is about to win it, assuming the current result stands). That is, returns the club who has scored more goals than the other one.

Returns: club object
winning team or None if the game is tied

get_winning_goal_scorer(self)

 

Returns the player who scored the so-called "winning goal". The winning goal of a match is the first goal for the winning team scoring which was "necessary" in light of the match scoreline. For instance, if the score is 4-2 to the home team, then the third goal scored by the home team is the "winning goal". A tied match has no winning goal or winning goal scorer.

Returns: player object
winning goal scorer, or None in case of a tie

is_higher_scoring_than(self, another_match)

 

Returns a boolean value indicating if the match had a higher number of goals than another given match.

Parameters:
  • another_match (match object) - another match which self match is compared to
Returns: bolean
True if self match had a higher total number of goals than the given one, False otherwise

See Also: #get_total_goals()

get_location(self)

 

Returns the name of the stadium at which the game is played. That is, returns the home club's home stadium.

Returns: string
stadium name