Commit 450a3696 by BellCodeEditor

save project

parent 1204277e
Showing with 22 additions and 6 deletions
......@@ -19,11 +19,27 @@ class Hero:
info = info1 + info2 + info3
print(info)
exit()
class Player(Hero):
def__init__(self,name):
super().__init__(name)
self.hp = 200
self.attack = 50
houyi=Player("后羿")
# 创建玩家类Player放入参数Hero
houyi=Player("后羿","射手")
yase=Hero("亚瑟")
print(houyi.hp)
print(houyi.attack)
# 创建__init__()函数方法并放入参数self,name,hero_type
# 使用super()函数继承父类方法__init__()并放入参数name
# 重写英雄血量200
# 重写英雄攻击力50
# 重写英雄类型
# 角色xx创建成功
# 当前等级, 血量,攻击力分别为 1,200,50
# 创建对象houyi参数"后羿", "射手"
# 创建对象yase
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