Commit 0d4114a0 by BellCodeEditor

save project

parent e2d4bf70
Showing with 7 additions and 3 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.hp=hp self.hp=hp
self.level=1 self.level=2
self.attack=attack self.attack=attack
self.name=name self.name=name
yese=Hero("亚瑟",300,20) yese=Hero("亚瑟",300,20)
print(yese.hp) print(yese.hp)
houyi=Hero("后羿",240,25) houyi=Hero("后羿",240,25)
print(houyi.hp) print(houyi.hp)
yese.hp=300+yese.level*50 def upgrade():
yese.attack=20+yese.attack*3 yese.hp=yese.hp+50
yese.attack=yese.attack+3
upgrade()
upgrade()
print(yese.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