Added a to_str function for all classes. __str__ function uses it. highscores_data uses the to_str function for saving.

This commit is contained in:
alwayscompiling
2022-08-03 22:35:27 -04:00
parent 66ace947c6
commit 6f4322bf6a
5 changed files with 41 additions and 5 deletions
+10 -1
View File
@@ -26,7 +26,7 @@ class Score:
Returns:
str: Score class as a string
"""
return f"{self.user}: {self.get_str()}"
return self.to_str()
@property
def user(self) -> str:
@@ -67,6 +67,15 @@ class Score:
"""
return str(self._value)
def to_str(self) -> str:
"""
Returns Score object as a string.
Returns:
str: string of json representation of Score
"""
return f"{self.user}: {self.get_str()}"
class ScoreTime(Score):
"""Class for a time based score. Inherits from Score."""