This is a simple library implementation for managing ongoing football matches and their scores, following the requirements provided in the task description. The library provides a way to start new matches, update scores, finish matches, and retrieve a summary of matches in progress ordered by their total score.
To use this library, you can follow these steps:
-
Clone the repository or integrate the provided classes into your project.
-
Create an instance of the
Scoreboard
class to manage ongoing matches:IScoreboard scoreboard = new Scoreboard();
-
Start matches, update scores, and finish matches using the provided methods:
// Start a new match scoreboard.StartMatch("Mexico", "Canada"); // Update scores for a match scoreboard.UpdateScore("Mexico", "Canada", 0, 5); // Finish a match scoreboard.FinishMatch("Mexico", "Canada");
-
Retrieve a summary of matches in progress ordered by their total score:
var matchesInProgress = scoreboard.GetMatchesInProgressOrderedByScore(); foreach (var match in matchesInProgress) { Console.WriteLine($"{match.HomeTeam} {match.HomeScore} - {match.AwayTeam} {match.AwayScore}"); }
The project includes unit tests to verify the functionality of the library. These tests are implemented using Xunit and can be run using a test runner of your choice.
-
Install the Xunit NuGet package if not already installed:
dotnet add package Xunit
-
Run the tests using the following command:
dotnet test
Please note the following assumptions made during the implementation:
- Match order identifiers are used to distinguish matches with the same total score. The higher the order identifier, the more recently the match was started.
- Team names are case-sensitive and must not be empty or contain only whitespace.
- Negative scores are not allowed for updates.
- Matches between the same teams cannot be started simultaneously.
If you have any feedback, suggestions for improvements, or encounter issues with the library, please feel free to open an issue on this repository.