Commit bf591f65 by BellCodeEditor

save project

parent af965ced
Showing with 26 additions and 0 deletions
class Hero(object):
def __init__(self,name):
self.level = 1
self.hp = 121
self.attack = 11
self.name = name
def combat(self,enemy):
enemy.hp -=self.attack
info1 = self.name+'对'+enemy.name+'发起攻击,'
info2 = self.name+'攻击力为'+str(self.attack)+','
if enemy.hp>0:
info3 = enemy.name+'的血量剩余'+str(enemy.hp)
info = info1+info2+info3
print(info)
else:
info3 = '血量为0,结束'
info = info1+info2+info3
print(info)
exit()
yase = Hero('亚瑟')
houyi = Hero('后羿')
while True:
houyi.combat(yase)
yase.combat(houyi)
\ 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