Commit 79d0dd1e by BellCodeEditor

save project

parent 5d92fa5d
Showing with 7 additions and 6 deletions
...@@ -4,12 +4,12 @@ class Hero: ...@@ -4,12 +4,12 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
y=Hero("1",300,20) def upgrade(self):
h=Hero("2",250,23)
def upgrade():
y.level=y.level+1 y.level=y.level+1
y.hp=y.hp+50 y.hp=y.hp+50
y.attack=y.attack+4 y.attack=y.attack+4
upgrade() houyi=Hero("h",240,23)
upgrade() houyi.upgrade()
print("等级:",houyi.level)
print("x:",houyi.hp)
print("gjl:",houyi.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