【发布时间】:2016-06-05 15:45:03
【问题描述】:
我需要解决的是:
Create class "Scores" and "Player".
Class score should have attributes level, score, time.
Class player should have as information a name and a list of Scores,
In class player implement the method maxLevel(),
which returns the max level achieved by the player.
我觉得这有点容易,但我还是想不通。
- 如何才能准确地列出分数?
- 完成上述操作后,如何访问每个玩家的得分列表?
谢谢!
我试过了,但我只知道我做错了。
class Score():
level = 0
score = 0
time = 0
def __init__(self,level,score,time):
Score.level = level
score.score = score
Score.time = time
class Player():
def __init__(self, name, scores):
self.name = name
self.scores = scores
def maxLevel():
##Do stuff to calculate the max
John = Player("John", [Score(100,1456,50), Score(210,1490,100)])
John.maxLevel()
【问题讨论】:
-
请展示您的研究和尝试。
-
已编辑,一定很糟糕,我是真正的初学者,谢谢!
标签: python list class attributes