Commit 9dce283a by BellCodeEditor

save project

parent b8e5bd9c
Showing with 24 additions and 0 deletions
class Hero(odject):
def __init__(selt,name):
selt.level = 1
selt.hp = 250
selt.attack = 40
selt.name = name
def combat(self,enemy):
inof1 = sejf.name+'对'+enemy.name+'发动了攻击'
inof2 = '造成了'+str(self.attack)+'点伤害'
enemy.hp -= self.attack
if enemy.hp > 0:
inof3=enemy.name+'还剩下'+str(enemy.hp)+'点血'
inof=inof1+inof2+inof3
print(inof)
else:
inof3=enemy.name+'已经死亡'
inof=inof1+inof2+inof3
print(inof)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houy1)
\ 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