Commit e503b16d by BellCodeEditor

auto save

parent cca50917
Showing with 11 additions and 4 deletions
...@@ -4,7 +4,14 @@ class Hero: ...@@ -4,7 +4,14 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade():
xiaobei.level=xiaobei.level+1
xiaobei.hp=xiaobei.hp+50
xiaobei.attack=xiaobei.attack+5
xiaobei=Hero("小贝",300,30) xiaobei=Hero("小贝",300,30)
nuoyi=Hero("诺依",200,20) print("小贝的初始血量为:",xiaobei.hp)
print("小贝的血量值为:",xiaobei.hp) upgrade()
print("诺依的攻击力为:",nuoyi.attack) upgrade()
\ No newline at end of file upgrade()
print("升3级后的血量值为:",xiaobei.hp)
\ 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