Commit 4c297764 by BellCodeEditor

save project

parent 25b5d8e5
Showing with 13 additions and 5 deletions
class Hero: class Hero:
def __init__(self,name): def __init__(self,name):
self.level=1 self.level=1
self.hp=200 self.hp=250
self.attack=40 self.attack=30
self.name=name self.name=name
def combat(self,enemy): def combat(self,enemy):
enemy.hp-=self.attack enemy.hp-=self.attack
...@@ -16,6 +16,14 @@ class Hero: ...@@ -16,6 +16,14 @@ class Hero:
info3=enemy.name+'阵亡,游戏结束' info3=enemy.name+'阵亡,游戏结束'
info=info1+info2+info3 info=info1+info2+info3
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)
\ No newline at end of file print(houyi.hp)
print(yase.hp)
\ No newline at end of file
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