Commit a7c188b8 by BellCodeEditor

save project

parent 5e87ffe9
Showing with 31 additions and 0 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
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))
def upgratea():
yase.level+=1
yase.hp+=50
yase.attack+=10
def upgrateb():
houyi.level+=1
houyi.hp+=50
houyi.attack+=10
upgratea()
upgrateb()
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