Commit 8c6aa354 by BellCodeEditor

save project

parent d3be48e0
Showing with 12 additions and 3 deletions
class Hero: class Hero:
def __init__(self,hp,attack): def __init__(self,hp,attack,name):
self.level=1 self.level=1
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
ys=Hero(300,20) self.name=name
hy=Hero(250,23) ys=Hero(300,20,"亚瑟")
hy=Hero(250,23,"后羿")
def upgrade(name):
name.level=name.level+1
name.hp=name.hp+1
name.attack=name.attack+1
upgrade(hy)
upgrade(hy)
print(hy.hp) print(hy.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