Commit dab794f8 by BellCodeEditor

save project

parent d6c81a0f
Showing with 20 additions and 0 deletions
class Hero:
def __init__(self,name,hp,att):
self.lv=1
self.name=name
self.hp=hp
self.att=att
yase=Hero('亚瑟',300,25)
print(f'{yase.name}(lv{yase.lv})的血量为:{yase.hp}')
def upgrade(hero):
hero.lv+=1
hero.hp+=50
hero.att+=4
upgrade(yase)
print(f'{yase.name}(lv{yase.lv})的血量为:{yase.hp}')
houyi=Hero('后羿',250,30)
print(f'{houyi.name}(lv{houyi.lv})的血量为:{houyi.hp}')
upgrade(houyi)
print(f'{houyi.name}(lv{houyi.lv})的血量为:{houyi.hp}')
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