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

Class Match

source code

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).
source code
 
get_home_club(self)
Returns the club who hosts the match.
source code
 
get_away_club(self)
Returns the club who is visiting the home club to play the match.
source code
 
add_goal(self, scorer)
Records a goal as having been scored in the match.
source code
 
get_home_goals(self)
Returns the number of goals scored by the home team.
source code
 
get_away_goals(self)
Returns the number of goals scored by the away team.
source code
 
get_total_goals(self)
Returns the total number of goals scored by the two teams.
source code
 
get_goal_difference(self)
Returns the goal difference of the match.
source code
 
get_winner(self)
Returns the club whose team won the match (or is about to win it, assuming the current result stands).
source code
 
get_winning_goal_scorer(self)
Returns the player who scored the so-called "winning goal".
source code
 
is_home_win(self)
Returns a boolean value indicating if the home team won.
source code
 
is_away_win(self)
Returns a boolean value indicating if the away team won.
source code
 
is_drawn(self)
Returns a boolean value indicating if the match ended in a draw.
source code
 
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.
source code
 
get_location(self)
Returns the name of the stadium at which the game is played.
source code

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)

source code 

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

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

get_home_club(self)

source code 

Returns the club who hosts the match.

Returns:
home club

get_away_club(self)

source code 

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

Returns:
away club

add_goal(self, scorer)

source code 

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 goalscorer. (If the given scorer is not employed by either club, the method does nothing.)

Parameters:
  • scorer - the player who scored the goal

get_home_goals(self)

source code 

Returns the number of goals scored by the home team.

Returns:
home team's goal count

get_away_goals(self)

source code 

Returns the number of goals scored by the away team.

Returns:
away team's goal count

get_total_goals(self)

source code 

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

Returns:
total goal count

get_goal_difference(self)

source code 

Returns the goal difference of the match. If the home team won, a positive integer indicating the win margin is returned. Similarly, a negative integer indicates an away win. A tied match has a goal difference of zero.

Returns:
goal difference

get_winner(self)

source code 

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:
winning team or None if the game is tied

get_winning_goal_scorer(self)

source code 

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:
winning goal scorer, or None in case of a tie

is_home_win(self)

source code 

Returns a boolean value indicating if the home team won.

Returns:
True if the home team won, False otherwise

is_away_win(self)

source code 

Returns a boolean value indicating if the away team won.

Returns:
True if the away team won, False otherwise

is_drawn(self)

source code 

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

Returns:
True if the neither team won, False otherwise

is_higher_scoring_than(self, another_match)

source code 

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

Parameters:
  • another_match - another match which self match is compared to
Returns:
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)

source code 

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

Returns:
stadium name