Commit 8455c80f by BellCodeEditor

save project

parent da9675d1
Showing with 13 additions and 5 deletions
...@@ -5,10 +5,18 @@ class Hero: ...@@ -5,10 +5,18 @@ class Hero:
self.hp = hp self.hp = hp
self.attack = attack self.attack = attack
def upgrade(): def upgrade(self):
yase.level=yase.level+1 self.level=self.level+1
yase.hp = yase.hp+20 self.hp = self.hp+20
yase.attack =yase.attack+50 self .attack =self.attack+50
yase = Hero("亚瑟",100,20) yase = Hero("亚瑟",100,20)
upgrade() yase.upgrade()
houyi = Hero("后羿",100,20)
houyi.upgrade()
harry = Hero("哈利",100,20)
harry.upgrade()
print("亚瑟的血量:",yase.hp) print("亚瑟的血量:",yase.hp)
print("后羿的血量:",houyi.hp)
print("哈利的血量:",harry.hp)
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