Commit 8e5cfffc by BellCodeEditor

auto save

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