Commit a33c27f5 by BellCodeEditor

save project

parent 4a3b0edf
Showing with 20 additions and 3 deletions
......@@ -5,6 +5,24 @@ class Hero(object):
self.hp = 3500
self.attack = 388
self.name = name
def
def combat(self,enemy):
enemy.hp=enemy.hp-self.attack
a1=self.name+"对"+enemy.name+"发起攻击"
a2="对"+enemy.name+"造成"+str(self.attack)+"伤害"
if enemy.hp<0:
a3=enemy.name+"阵亡"
a=a1+a2+a3
print(a)
else:
a3=enemy.name+"还剩"+str(enemy.hp)+"血"
a=a1+a2+a3
print(a)
yase=Hero("亚瑟")
houyi=Hero("后羿")
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