Commit 7d5ed80a by BellCodeEditor

save project

parent 365cf1e4
Showing with 12 additions and 5 deletions
# 英雄角色类
class Hero(object):
class Hero:
def __init__(self, name):
self.level = 1
self.hp = 3500
......@@ -16,7 +16,14 @@
info3 = enemy.name + '还剩下' + str(enemy.hp) + '点生命值'
print(info1 + info2 + info3)
class Player(Hero):
def __init__(self,enemy,hero_type):
super().__init__(name)
self.hp=3400
self.attack=400
self.hero_type=hero_type
lx= Hero("李信")
houyi= Hero("后羿")
lx.combat(houyi)
\ No newline at end of file
lx= Player("李信","战士")
yase= Hero("亚瑟")
#yase.combat(lx)
print("角色"+lx.name+"创建成功,英雄类型为:",self.level,self.hp,self.attack)
\ 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