Commit 3aede3d2 by BellCodeEditor

save project

parent a1f81f72
Showing with 9 additions and 9 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name,level,hp,attack):
self.name=name self.name=name
self.level=level self.level=level
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
yase=Hero("垭瑟",1,300,20) yase=Hero("垭瑟",1,300,20)
houyi=Hero("后裔",1,250,23) houyi=Hero("后裔",1,250,23)
yase.upgrade()
houyi.upgrade()
print(yase.hp) print(yase.hp)
print(houyi.hp) print(houyi.hp)
def upgrade(): \ No newline at end of file
yase.level=yase.level+1
yase.hp=yase.hp+50
yase.attack=attack+4
upgrade()
upgrade()
\ 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