Commit 602cfd2d by BellCodeEditor

save project

parent 4822cce2
Showing with 8 additions and 3 deletions
...@@ -6,7 +6,6 @@ class Hero(object): ...@@ -6,7 +6,6 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(self,enemy): def combat(self,enemy):
enemy.hp = enemy.hp - self.attack enemy.hp = enemy.hp - self.attack
info1 = self.name + "对" + enemy.name + "发起了进攻" info1 = self.name + "对" + enemy.name + "发起了进攻"
...@@ -19,8 +18,14 @@ class Hero(object): ...@@ -19,8 +18,14 @@ class Hero(object):
info4 = enemy.name + "阵亡,游戏结束" info4 = enemy.name + "阵亡,游戏结束"
info = info1 + info2 + info4 info = info1 + info2 + info4
print(info) print(info)
class Player(Hero):
def __init__(self, name):
super().__init__(name)
self.hp = 200
self.attack = 50
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Player("后羿")
yase.combat(houyi) yase.combat(houyi)
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