Commit 7181f3ab by BellCodeEditor

auto save

parent 064df631
Showing with 11 additions and 4 deletions
...@@ -3,7 +3,14 @@ class Hero: ...@@ -3,7 +3,14 @@ class Hero:
self.level=1 self.level=1
self.hp=300 self.hp=300
self.attack=20 self.attack=20
def upgrade(self):
self.level=self.level+1
self.hp = self.hp+50
self.attack=self.attack+4
yase=Hero() houyi=Hero("后羿",240,23)
print("yase的血量值为"yase.hp) houyi.upgrade()
print("yase的攻击力为"yase.attack) print("等级为:",houyi.level)
\ No newline at end of file print("血量为"yase.hp)
print("攻击力为"yase.attack)
\ 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