Commit e972688a by BellCodeEditor

save project

parent bdda9ed7
Showing with 12 additions and 2 deletions
...@@ -21,7 +21,11 @@ class Hero: # 英雄类 ...@@ -21,7 +21,11 @@ class Hero: # 英雄类
print(info) print(info)
exit() exit()
def cure(self):
self.hp+=50
if self.hp>self.max_hp:
self=self.max_hp
print(self.name+"使用了治疗,血量增加:",60,"目前血量为:",self.hp)
class Player(Hero): # 玩家英雄 class Player(Hero): # 玩家英雄
def __init__(self,name): def __init__(self,name):
super().__init__(name) super().__init__(name)
...@@ -29,7 +33,13 @@ class Player(Hero): # 玩家英雄 ...@@ -29,7 +33,13 @@ class Player(Hero): # 玩家英雄
self.attack=50 self.attack=50
print("玩家的血量值为:",self.hp) print("玩家的血量值为:",self.hp)
print("玩家的攻击力为:",self.attack) print("玩家的攻击力为:",self.attack)
def cure(self):
self.hp+=50
if self.hp>self.max_hp:
self=self.max_hp
player = Player("后羿")
player = Player("后羿")
player.cure()
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