Commit a0fa8576 by BellCodeEditor

save project

parent 6d9f43d7
Showing with 17 additions and 7 deletions
class Hero(): class Hero():
def __init__(self): def __init__(self,name,hp,attack):
self.hp=300 self.name=name
self.hp=hp
self.level=1 self.level=1
self.attack=20 self.attack=attack
def upgrade(self):
yase = Hero() self.hp +=50
print(yase.hp) self.level +=1
\ No newline at end of file self.attack +=10
yase = Hero('yase',300,20)
print(yase.hp)
yase.upgrade()
print(yase.hp)
huoyi = Hero('huoyi',240,80)
huoyi.upgrade()
print(huoyi.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