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:
+10
-1
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user