Commit 491c8629 by BellCodeEditor

auto save

parent d26bd8e5
Showing with 8 additions and 7 deletions
...@@ -23,12 +23,13 @@ class Hero: # 英雄类 ...@@ -23,12 +23,13 @@ class Hero: # 英雄类
class Player(Hero): # 玩家英雄 class Player(Hero): # 玩家英雄
def __init__(self,name): def __init__(self,name,hero_type,hp,attack):
super().__init__(name) super().__init__(name)
self.hp = 200 self.hp = hp
self.attack = 30 self.attack = attack
self.hero_type = hero_type
print("英雄的名字、类型分别为:",self.name,self.hero_type)
print("英雄的生命、攻击力分别为:",self.hp,self.attack)
player1 = Player("后羿",'射手',240,40)
player = Player("后羿") player2 = Player("亚瑟",'战士',300,30)
print("玩家的血量值为:",player.hp)
print("玩家的攻击力为:",player.attack)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment