Commit 96c6c4b1 by BellCodeEditor

save project

parent 17e5120c
Showing with 1478 additions and 3 deletions
...@@ -2,6 +2,1482 @@ ...@@ -2,6 +2,1482 @@
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.level = 1 self.level = 1
self.hp= self.hp=200
self.attack = 388 self.attack = 388
self.name = name
\ No newline at end of file def combat(self,enemy):
enemy.hp-=self.attack
infor1=self.name+'对'+enemy.name+'发起进攻,'
infor2='造成'+str(self.attack)+'点伤害,'
infor3=enemy.name+'还有'+str(enemy.hp)+'血量。'
if enemy.hp>0:
print(infor1+infor2+infor3)
else:
print(infor1+infor2+enemy.name+'噶了!')
exit()
yase=Hero('亚瑟')
houyi=Hero('后羿')
yase.combat(houyi)
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