Commit 4c297764 by BellCodeEditor

save project

parent 25b5d8e5
Showing with 12 additions and 3 deletions
class Hero:
def __init__(self,name):
self.level=1
self.hp=200
self.attack=40
self.hp=250
self.attack=30
self.name=name
def combat(self,enemy):
enemy.hp-=self.attack
......@@ -16,6 +16,14 @@ class Hero:
info3=enemy.name+'阵亡,游戏结束'
info=info1+info2+info3
print(info)
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp=200
self.attack=50
yase=Hero('亚瑟')
houyi=Hero('后羿')
houyi=Player('后羿')
yase.combat(houyi)
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