Commit 39eee59a by BellCodeEditor

auto save

parent 22354288
Showing with 28 additions and 0 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def upgrate(self):
self.level+=1
self.hp+=50
self.attack+=5
yase = Hero('亚瑟',300,35)
houyi=Hero("后羿",240,40)
print(yase.name+"的等级是"+str(yase.level))
print(yase.name+"的血量是"+str(yase.hp))
print(yase.name+"的攻击力是"+str(yase.attack))
print(houyi.name+"的等级是"+str(houyi.level))
print(houyi.name+"的血量是"+str(houyi.hp))
print(houyi.name+"的攻击力是"+str(houyi.attack))
for i in range(99999):
yase.upgrate()
houyi.upgrate()
print('升级后'+yase.name+"的等级是"+str(yase.level))
print('升级后'+yase.name+"的血量是"+str(yase.hp))
print('升级后'+yase.name+"的攻击力是"+str(yase.attack))
print('升级后'+houyi.name+"的等级是"+str(houyi.level))
print('升级后'+houyi.name+"的血量是"+str(houyi.hp))
print('升级后'+houyi.name+"的攻击力是"+str(houyi.attack))
\ 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