Commit a3f1b640 by BellCodeEditor

save project

parent 03f42ab5
Showing with 11 additions and 6 deletions
# 英雄角色类
class Hero(object):
class Hero():
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,enemy): # 攻击
enemy.hp-=self.attack
if enemy.hp>0:
print(self.name+"sb"+enemy.name+str(self.attack)+"sb")
else:
print(enemy.name+"阵亡了!")
exit()
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
for i in range(10):
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