Class ScoreManager

java.lang.Object
spinhex.score.ScoreManager

public class ScoreManager extends Object
Manages the storage and retrieval of Score objects. This class provides functionality to add new scores and retrieve all scores from a file.
  • Constructor Details

    • ScoreManager

      public ScoreManager(Path filePath)
      Constructs a new ScoreManager with the specified file path.
      Parameters:
      filePath - the path to the file where scores will be stored
  • Method Details

    • add

      public List<Score> add(Score result) throws IOException
      Adds a new score to the list of scores and saves it to the file.
      Parameters:
      result - the Score object to add
      Returns:
      the updated list of all scores including the newly added score
      Throws:
      IOException - if an I/O error occurs while writing to the file
    • getAll

      public List<Score> getAll() throws IOException
      Retrieves all scores from the file. If the file doesn't exist, returns an empty list.
      Returns:
      a list of all Score objects stored in the file
      Throws:
      IOException - if an I/O error occurs while reading from the file