Commit c3afa2b2 by BellCodeEditor

auto save

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