#Game游戏类
from random import randint
class Game(object):
top_score=0
@staticmethod
def show_help():
print("This is help doc.")
@classmethod
def show_top_score(cla):
print(f"The top score is {Game.top_score}!!!")
#print(f"The top score is {Game.top_score}!!!")
#类属性也可以用 cla. 调用
print(f"The top score is {cla.top_score}!!!")
def __init__(self,name):
self.name=name
def strat_game(self):
a=randint(1,100)
print(f"{self.name} score is {a}.")
if a>Game.top_score:
Game.top_score=a
print(f"现在最高分是你!{self.name} Cons")
return
a=Game("lize")
b=Game("Shipengfei")
a.show_help()
Game.show_top_score()
a.strat_game()
b.strat_game()
Game.show_top_score()