Commit 876f11ea by BellCodeEditor

save project

parent 6889f731
Showing with 9 additions and 2019 deletions
class hero: class hero:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.level=1 self.level=1
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade(self): yese=hero("亚瑟”,300,20)
self.level=self.level+1 houyi=hero("后羿",240,23)
self.hp=self.hp+50 print("亚瑟血量:',yase.hp)
self.attack=self.attack+4 print("后裔血量:',houyi.hp)
houyi=hero("后裔",240,23) \ No newline at end of file
houyi.upgrade()
houyi=hero("亚瑟",300,20)
print("血量",houyi.hp)
print("攻击力",houyi.atttack)
print("等级",houyi.level)
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