Commit 0452ddb8 by BellCodeEditor

save project

parent 12b8d85c
Showing with 9 additions and 6 deletions
...@@ -4,11 +4,13 @@ class Hero: ...@@ -4,11 +4,13 @@ class Hero:
selt.name = name selt.name = name
selt.hp = hp selt.hp = hp
selt.attack = attack selt.attack = attack
def upgrade(): def upgrade(selt):
yase.level = yase.level + 1 selt.level = selt.level + 1
yase.hp = yase.hp + 200 selt.hp = selt.hp + 200
yase.attack = yase.attack + 100 selt.attack = selt.attack + 100
yase = Hero("亚瑟",200,20) yase = Hero("亚瑟",200,20)
upgrade() houyi = Hero("后羿",150,15)
yase.upgrade()
houyi.upgrade()
print("亚瑟的血量:",yase.hp) print("亚瑟的血量:",yase.hp)
print("后羿的血量:",yase.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