Commit b9561b20 by BellCodeEditor

save project

parent 956fe835
Showing with 9 additions and 15 deletions
...@@ -3,21 +3,16 @@ class Hero: ...@@ -3,21 +3,16 @@ class Hero:
self.hp=hp self.hp=hp
self.level=1 self.level=1
self.attach=attach self.attach=attach
def upgrade():
lanlingwang.hp=lanlingwang.hp+150 def upgrade(self):
lanlingwang.level=lanlingwang.level+1 self.hp=self.hp+150
lanlingwang.attach=lanlingwang.attach+100 self.level=self.level+1
def upgrade1(): self.attach=self.attach+100
sunce.hp=sunce.hp+150
sunce.level=sunce.level+1
sunce.attach=sunce.attach+100
lanlingwang=Hero(1300,50,'兰陵王') lanlingwang=Hero(1300,50,'兰陵王')
lanlingwang.upgrade()
sunce=Hero(1500,30,'孙策') sunce=Hero(1500,30,'孙策')
sunce.upgrade()
print('兰陵王的血量为: ',lanlingwang.hp) print('兰陵王的血量为: ',lanlingwang.hp)
upgrade()
upgrade()
print('兰陵王升2级后的血量为: ',lanlingwang.hp)
print('孙策的血量为: ',sunce.hp) print('孙策的血量为: ',sunce.hp)
upgrade1()
upgrade1()
print('孙策升2级的血量为: ',sunce.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