Commit e4316186 by BellCodeEditor

save project

parent 5f80d817
Showing with 8 additions and 7 deletions
class Hero: #类
def __init__(self,name,hp,attack):
class Hero: #类
def __init__(self,name,hp,attack): #设置属性
self.name=name
self.hp=hp
self.leve=1
self.attack=attack
def upgrade(self):
def upgrade(self): #升级加属性
self.leve+=1
self.hp+=50
self.attack+=5
www=Hero("sdeg",300,20)
www=Hero("sdeg",300,20) #sdeg角色升级,打印hp的值
www.upgrade()
www.upgrade()
print(www.hp)
qqq=Hero("刘艺航",100000,999999)
qqq=Hero("刘艺航",100000,999999) #刘艺航角色升级,打印hp的值
qqq.upgrade()
qqq.upgrade()
print(qqq.hp)
\ No newline at end of file
print(qqq.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