Commit c3afa2b2 by BellCodeEditor

auto save

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