Commit 914a38b6 by BellCodeEditor

save project

parent a8c8ef43
Showing with 10 additions and 7 deletions
class Hero: #创建类 class Hero: #创建类
def __init__(self): #创建属性 def __init__(self,name,level,hp,attack): #创建属性
self.level=1 self.name=name
self.hp=200 self.level=level
self.attack=25 self.hp=hp
self.attack=attack
xiaodaidai=Hero()
print(xiaodaidai.attack) xiaodaidai=Hero("小呆呆",1,200,25)
haimianbaobao=Hero("海绵宝宝"121020)
print("英雄名称为:"+xiaodaidai.name)
print("海绵宝宝的血量是:",haimianbaobao.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