diff --git a/data/category.py b/data/category.py index 0ec1cf3..3604e2b 100644 --- a/data/category.py +++ b/data/category.py @@ -8,20 +8,17 @@ from data.score import Score, ScoreTime # pylint: disable=import-error class Category: """Stores a category's information and relative scores.""" - def __init__(self, name: str, ascending: bool, time_record: bool, score_map: dict) -> None: + def __init__(self, name: str) -> None: """ - Default constructor for Category class. + Default constructor for Category class. Creates empty category and populates with defaults. Args: name (str): Category's name - ascending (bool): If category is ascending or decending - time_record (bool): If category is time record or not - score_map (dict): map of Scores """ self._name: str = name - self._ascending: bool = ascending - self._time_record: bool = time_record - self._scores_map: dict = score_map + self._ascending: bool = False + self._time_record: bool = False + self._scores_map: dict = {} def __str__(self) -> str: """ @@ -44,16 +41,16 @@ class Category: Returns: Category: Populated Category object """ - ascending = data["ascending"] - time_record = data["time_record"] - score_map = {} + category = cls(name) + category.ascending = data["ascending"] + category.time_record = data["time_record"] for user, score in data["scores"].items(): - if time_record: - score_map[user] = ScoreTime(user, score) + if category.time_record: + category.add_score(ScoreTime(user, score)) else: - score_map[user] = Score(user, score) + category.add_score(Score(user, score)) - return cls(name, ascending, time_record, score_map) + return category @property def ascending(self) -> bool: