# 定义游戏类
class Game:
# 定义类属性,历史最高分
top_score = 9
# 定义初始化对象属性
def __init__(self, name,code):
self.name = name
self.code = code
# 显示游戏帮助,使用静态方法
@staticmethod
def help():
print('游戏帮助信息:不断刷新即可')
#定义最高分的方法
# 定义类方法,显示历史最高分
# def top(self):
# top_score=max(code)
@classmethod
def show_top_score(cls):
print('历史记录最高分是%s' % cls.top_score)
# 游戏开始
def start(self):
print("%s游戏开始了,你的切西瓜数是%s" % (self.name,self.code))
# 3.历史最高分
Game.show_top_score()
Game.help()
a=Game('小虎',code=random.randint(1,10))
a.start()