Skip to content

mohsenetc/footbal-scroreboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Live Football World Cup Scoreboard Library

This project is a simple Java library designed to manage and display live scores for football matches during the World Cup. It allows for adding matches, updating scores, finishing matches, and retrieving a summary of ongoing matches.

Features

  • Start new matches with initial scores of 0-0.
  • Update scores for ongoing matches.
  • Finish matches and remove them from the scoreboard.
  • Retrieve a summary of ongoing matches ordered by total score and start time.

Requirements

  • Java 21
  • JUnit 5 (for testing)
  • Maven

Getting Started

Installation

  1. Clone the repository:
      git clone <repository_url>
  2. Navigate to the project directory:
       cd <project_directory>
  3. Build the project:
       mvn clean install

Usag

  1. Create a Scoreboard Instance:
Scoreboard scoreboard = new Scoreboard();
  1. Start a New Match:
scoreboard.startMatch("Home Team", "Away Team");
  1. Update Scores:
scoreboard.updateScore("Home Team", 1, 2); // Home team 1, Away team 2
  1. Finish a Match:
scoreboard.finishMatch("Home Team");
  1. Get Matches Summary:
    List<Match> summary = scoreboard.getMatchesSummary();
    for (Match match : summary) {
        System.out.println(match);
    }

Example

Here’s a complete example of using the library:

public class Main {
public static void main(String[] args) {
Scoreboard scoreboard = new Scoreboard();

        // Start matches
        scoreboard.startMatch("Mexico", "Canada");
        scoreboard.startMatch("Spain", "Brazil");

        // Update scores
        scoreboard.updateScore("Mexico", 0, 5);
        scoreboard.updateScore("Spain", 10, 2);

        // Get summary
        List<Match> summary = scoreboard.getMatchesSummary();
        for (Match match : summary) {
            System.out.println(match);
        }
    }
}

Running Tests

To run the tests for this library, ensure you have JUnit 5 configured in your project, and then execute:

mvn test

Assumptions

  • Each match is uniquely identified by the home team name.
  • The library does not implement a persistence layer; all data is stored in memory.

Contributing

Contributions are welcome! Please create a pull request or submit issues for improvements.

Next Steps

  • Enhance Error Handling: Consider adding error handling for cases like updating scores for non-existing matches.
  • Improve Validation: Validate team names and scores before processing.
  • Add Additional Features: Consider adding functionality for features like getting the list of finished matches or getting a specific match by team name.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages