Commit cd5d68cd by BellCodeEditor

auto save

parent bbb04678
Showing with 17 additions and 4 deletions
class Hero: class Hero:
def __init__(self): def __init__(self,name,hp,attack):
self.level=1 self.level=1
self.hp=300 self.name=name
self.attack=20 self.hp=hp
self.attack=attack
def upgrate(self):
self.level=self.level
self.hp=self.hp+100
self.attack=self.attack+10
YaSe=Hero("YaSe",300,20)
HouYi=Hero("HouYi",240,23)
YaSe.upgrate()
H
YaSe=Hero()
print(Yase.level) print(Yase.level)
print(Yase.hp) print(Yase.hp)
print(HouYi level)
print(HouYi hp)
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