Package football1 :: 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 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 created 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_home_goal(self)
Records a goal as having been scored in the match by the home team.
 
add_away_goal(self)
Records a goal as having been scored in the match by the away team.
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, >= 0
get_goal_difference(self)
Returns the goal difference of the match as an absolute value (absolute value: 2 - 3 returns 1).
int
get_total_goals(self)
Returns the total number of goals scored by the two teams.
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.
boolean
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

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_goal_difference(self)

 

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

Returns: int, >= 0
goal difference

get_total_goals(self)

 

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

Returns: int
total goal count

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

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 this match is compared to
Returns: boolean
True if this 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