Commit 60447ec8 by BellCodeEditor

save project

parent da60e227
Showing with 24 additions and 0 deletions
# 英雄角色类
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 3500
self.attack = 388
self.name = name
def gongji(self,one):
one.hp-=self.attack
first=self.name+"对"+one.name+"发起攻击"
second="造成"+str(self.attack)+"点伤害"
if one.hp<0:
t=one.name+"die"
else:
t=one.name+"还剩"+str(one.hp)+"血量"
print(first+second+t)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.gongji(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