Commit 5d74f7bc by BellCodeEditor

save project

parent d6c81a0f
Showing with 25 additions and 0 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
xiaobei=Hero("小贝",300,80)
def upgrade():
xiaobei.level=xiaobei.level+1
xiaobei.hp=xiaobei.hp+50
xiaobei.attack=xiaobei.attack=5
print("小贝的初始血量是:",xiaobei.hp)
print("小贝的初始攻击力是:",xiaobei.attack)
upgrade()
upgrade()
upgrade()
upgrade()
print("提高4级后小贝的血量是:",xiaobei.hp)
print("提高4级后小贝的攻击力是:",xiaobei.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