Commit 537421bf by BellCodeEditor

save project

parent caa61f88
Showing with 9 additions and 4 deletions
...@@ -4,10 +4,15 @@ class Hero: ...@@ -4,10 +4,15 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
yese=Hero("亞瑟",300,20) def upgrade(self):
def upgrade():
yese.level=yese.level+1 yese.level=yese.level+1
yese.hp=yese.hp+50 yese.hp=yese.hp+50
yese.attack=yese.attack+4 yese.attack=yese.attack+4
upgrade() houyi=Hero("后羿",240,23)
upgrade() houyi.upgrade()
print(houyi.level)
print(houyi.hp)
print(houyi.attack)
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