Kind: global class
- Match
- new Match(homeTeam, awayTeam)
- instance
- .id ⇒
string - .totalScore ⇒
number - .setScore(homeTeamScore, awayTeamScore)
- .id ⇒
- static
Creates a new Match instance.
Throws:
ValidationErrorIf the team names are invalid.
| Param | Type | Description |
|---|---|---|
| homeTeam | string |
The name of the home team. |
| awayTeam | string |
The name of the away team. |
Gets the unique ID for the match.
Kind: instance property of Match
Returns: string - The unique ID for the match.
Gets the total score for the match.
Kind: instance property of Match
Returns: number - The total score for the match.
Sets the score for the match.
Kind: instance method of Match
Throws:
ValidationErrorIf the scores are not positive integers.
| Param | Type | Description |
|---|---|---|
| homeTeamScore | number |
The score of the home team. |
| awayTeamScore | number |
The score of the away team. |
Generates a unique ID for the match based on the team names.
Kind: static method of Match
Returns: string - The unique ID for the match.
Throws:
ValidationErrorIf the team names are invalid.
| Param | Type | Description |
|---|---|---|
| homeTeam | string |
The name of the home team. |
| awayTeam | string |
The name of the away team. |
Validates the team names.
Kind: static method of Match
Throws:
ValidationErrorIf the team names are invalid.
| Param | Type | Description |
|---|---|---|
| homeTeam | string |
The name of the home team. |
| awayTeam | string |
The name of the away team. |
Kind: global class
Creates a new ScoreBoard instance.
scoreBoard.startMatch(homeTeam, awayTeam) ⇒ Match
Starts a new match between the specified home and away teams.
Kind: instance method of ScoreBoard
Returns: Match - The newly created Match instance.
Throws:
MatchExistsErrorIf a match with the specified teams already exists.ValidationErrorIf the team names are invalid.
| Param | Type | Description |
|---|---|---|
| homeTeam | string |
The name of the home team. |
| awayTeam | string |
The name of the away team. |
scoreBoard.getMatch(homeTeam, awayTeam) ⇒ Match | null
Retrieves an existing match between the specified home and away teams.
Kind: instance method of ScoreBoard
Returns: Match | null - The Match instance if found, otherwise null.
Throws:
ValidationErrorIf the team names are invalid.
| Param | Type | Description |
|---|---|---|
| homeTeam | string |
The name of the home team. |
| awayTeam | string |
The name of the away team. |
scoreBoard.getMatches() ⇒ Array.<Match>
Retrieves all matches, sorted by total score in descending order and by creation date in descending order if scores are equal.
Kind: instance method of ScoreBoard
Returns: Array.<Match> - An array of Match instances.
Finishes and removes the match between the specified home and away teams.
Kind: instance method of ScoreBoard
Throws:
ValidationErrorIf the team names are invalid.MatchNotFoundErrorIf the match is not found.
| Param | Type | Description |
|---|---|---|
| homeTeam | string |
The name of the home team. |
| awayTeam | string |
The name of the away team. |