. 1 class Game (Object): 2 # define the highest classification attribute . 3 top_score = 0 . 4 . 5 # initialization . 6 DEF the __init__ (Self, name): . 7 the self.name = name . 8 . 9 10 # game Help static method . 11 @staticmethod 12 is DEF game_help (): 13 Print ( " Tip: do not let the zombies into the house " ) 14 15 # highest classification 16 @classmethod 17 DEF show_top_score (CLS): 18 is Print ( " game is highest score:% D " % cls.top_score) . 19 20 is # play method of Example 21 is DEF start_game (Self): 22 is Print ( " % S to start the game " % the self.name) 23 is 24 # Display help 25 Game.game_help () 26 # to display the highest score of 27 Game.show_top_score () 28 # Xiao Ming to play the game 29 xiaoming = game ( " Bob " ) 30 xiaoming.start_game ()
Tip: do not let the zombies into the home game is the highest score: 0 Xiaoming start playing