Commit 80ca61fc by BellCodeEditor

save project

parent 1993aafb
Showing with 12 additions and 9 deletions
...@@ -4,14 +4,17 @@ class Hero(): ...@@ -4,14 +4,17 @@ class Hero():
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
self.name=name self.name=name
def upgrade(name):
name.level=name.level+1
name.hp=name.hp+50
name.attack=name.attack+4
yase=Hero('亚瑟',300,30) yase=Hero('亚瑟',300,30)
houyi=Hero('后羿',250,23) houyi=Hero('后羿',250,23)
def upgrade(): yase.upgrade()
yase.level=yase.level+1 houyi.upgrade()
yase.hp=yase.hp+50
yase.attack=yase.attack+4
upgrade()
upgrade()
print(yase.hp) print(yase.hp)
print(yase.attack) print(yase.attack)
print(yase.level) print(yase.level)
\ No newline at end of file print(houyi.hp)
print(houyi.attack)
print(houyi.level)
\ 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