Skip to content

sanks/score-board

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Classes

Match
ScoreBoard

Match

Kind: global class

new Match(homeTeam, awayTeam)

Creates a new Match instance.

Throws:

  • ValidationError If the team names are invalid.
Param Type Description
homeTeam string The name of the home team.
awayTeam string The name of the away team.

match.id ⇒ string

Gets the unique ID for the match.

Kind: instance property of Match
Returns: string - The unique ID for the match.

match.totalScore ⇒ number

Gets the total score for the match.

Kind: instance property of Match
Returns: number - The total score for the match.

match.setScore(homeTeamScore, awayTeamScore)

Sets the score for the match.

Kind: instance method of Match
Throws:

  • ValidationError If 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.

Match.getId(homeTeam, awayTeam) ⇒ string

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:

  • ValidationError If the team names are invalid.
Param Type Description
homeTeam string The name of the home team.
awayTeam string The name of the away team.

Match.validateTeams(homeTeam, awayTeam)

Validates the team names.

Kind: static method of Match
Throws:

  • ValidationError If 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

Kind: global class

new ScoreBoard()

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:

  • MatchExistsError If a match with the specified teams already exists.
  • ValidationError If 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:

  • ValidationError If 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.

scoreBoard.finishMatch(homeTeam, awayTeam)

Finishes and removes the match between the specified home and away teams.

Kind: instance method of ScoreBoard
Throws:

  • ValidationError If the team names are invalid.
  • MatchNotFoundError If the match is not found.
Param Type Description
homeTeam string The name of the home team.
awayTeam string The name of the away team.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published