Football1 Docs
Fall 2026
API

# Match

o1.football1.Match
class Match(val `home`: Club, val `away`: Club)

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.

The class is expected to be used as follows. When a real-leaf match starts, a match object is created to represent it; the match initially has zero goals. Goals are then added incrementally (by calling addHomeGoal or addAwayGoal) as the match progresses. (This means that a match object has a mutable state.)

## Parameters

away

  the club whose team plays away in the match

home

  the club whose team plays at home in the match

## Attributes

Graph
Supertypes
  class Object
  trait Matchable
  class Any

## Members list

### Value members

#### Concrete methods

def addAwayGoal(): Unit

Records a goal as having been scored in the match by the away team.

Records a goal as having been scored in the match by the away team.

## Attributes

def addHomeGoal(): Unit

Records a goal as having been scored in the match by the home team.

Records a goal as having been scored in the match by the home team.

## Attributes

def awayGoals: Int

Returns the number of goals that have been scored (so far) by the away team.

Returns the number of goals that have been scored (so far) by the away team.

## Attributes

def goalDifference: Int

Returns the goal difference of the match. The sign of the number indicates which team scored more goals.

Returns the goal difference of the match. The sign of the number indicates which team scored more goals.

## Attributes

Returns

  the goal difference as a positive number if the home team won, a negative number if the away team won, or zero if the match is a tie

def homeGoals: Int

Returns the number of goals that have been scored (so far) by the home team.

Returns the number of goals that have been scored (so far) by the home team.

## Attributes

def isAwayWin: Boolean

Returns a Boolean value indicating whether the away team won (or would win if the match ended with the current score). Tied scores produce `false`.

Returns a Boolean value indicating whether the away team won (or would win if the match ended with the current score). Tied scores produce `false`.

## Attributes

def isGoalless: Boolean

Determines whether this match is entirely goalless, that is, whether neither team has scored a single goal.

Determines whether this match is entirely goalless, that is, whether neither team has scored a single goal.

## Attributes

def isHigherScoringThan(`anotherMatch`: Match): Boolean

Determines whether this match has a higher total score than another given match.

Determines whether this match has a higher total score than another given match.

## Attributes

Returns

  `true` if more goals were scored in total in this match than in the given match, `false` otherwise

def isHomeWin: Boolean

Returns a Boolean value indicating whether the home team won (or would win if the match ended with the current score). Tied scores produce `false`.

Returns a Boolean value indicating whether the home team won (or would win if the match ended with the current score). Tied scores produce `false`.

## Attributes

def isTied: Boolean

Returns a Boolean value indicating whether the game ended in a draw (or would do so if the match ended with the current score).

Returns a Boolean value indicating whether the game ended in a draw (or would do so if the match ended with the current score).

## Attributes

def location: String

Returns the name of the stadium where the match is played. That is, returns the name of the home team’s stadium.

Returns the name of the stadium where the match is played. That is, returns the name of the home team’s stadium.

## Attributes

override def toString: String

Produces a textual description of the match’s current state, in a format illustrated by the examples below. In these examples, `Liverpool` is the name of the home team, `Everton` the name of the away team, and `Anfield` the name of the home team’s stadium.

Produces a textual description of the match’s current state, in a format illustrated by the examples below. In these examples, `Liverpool` is the name of the home team, `Everton` the name of the away team, and `Anfield` the name of the home team’s stadium.

Goalless draw (no goals for either side):

    Liverpool vs. Everton at Anfield: tied at nil-nil

Other tied score (e.g., 2–2):

    Liverpool vs. Everton at Anfield: tied at 2-all

Home score higher (e.g., 4–0):

    Liverpool vs. Everton at Anfield: 4-0 to Liverpool

Away score higher (e.g., 2–4):

    Liverpool vs. Everton at Anfield: 4-2 to Everton

Note that although the name of the home team is always listed first, but the leader’s score is shown first, even if the away team is leading.

## Attributes

Definition Classes
  Any

def totalGoals: Int

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

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

## Attributes

#### Concrete fields

val away: Club
val home: Club