Commit 0a7f924d by BellCodeEditor

auto save

parent f47689a4
Showing with 16 additions and 0 deletions
class Hero:
#类的属性,需要加init
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
#类的方法(这个是可以省略的)
#调用下,实例化亚瑟对象
yase=Hero("亚瑟",300,20)
houyi=Hero("后羿",120,50)
print(yase.name,yase.hp)
print(houyi.name,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