Commit 8e5cfffc by BellCodeEditor

auto save

parent e572c18c
Showing with 9 additions and 9 deletions
#定义一个英雄类(Hero) #定义一个英雄类(Hero)
class Hero: class Hero:
#定义init方法 #定义init方法
def __init__(self,?,?,?): def __init__(self,name,hp,attack):
#定义属性值(name,level=1,hp=300,attack=20) #定义属性值(name,level=1,hp=300,attack=20)
? self.level=1
? self.name=name
? self.hp=hp
? self.attack=attack
#实例对象yase,houyi #实例对象yase,houyi
yase=Hero(?,?,?) yase=Hero('亚瑟',300,20)
houyi=? houyi=?
#打印yase的血量hp #打印yase的血量hp
print('亚瑟的血量为:'+) print('亚瑟的血量为:'+str(yase.hp))
#打印houyi的血量hp #打印houyi的血量hp
print('后裔的血量为:'+) print('后裔的血量为:'+str(houyi.hp))
\ No newline at end of file \ 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