Commit 298257ff by BellCodeEditor

save project

parent 9a581ef4
Showing with 14 additions and 3 deletions
...@@ -6,9 +6,19 @@ class Hero(object): ...@@ -6,9 +6,19 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(): # 攻击 def combat(self,enmiy): # 攻击
??? a=self.name+'对'+enmiy.name+'发起进攻,'
b='造成'+str(self.attack)+'点伤害,'
enmiy.hp-=self.attack
if enmiy.hp>0:
c=enmiy.name+'还剩下'+str(enmiy.hp)+'血量'
d=a+b+c
print(d)
else:
e=enmiy.name+'阵亡'
f=a+b+e
print(f)
exit()
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) 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