Commit b4fe72ca by BellCodeEditor

save project

parent 96f5bea6
Showing with 16 additions and 5 deletions
# 英雄角色类
class Hero(object):
class Hero():
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
self.max_hp=self.hp
def combat(self,enemy): # 攻击
......@@ -20,6 +21,16 @@ class Hero(object):
info = info1 + info2 + info3
print(info)
exit()
yase = Hero("满级老6")
houyi= Hero("卢本伟")
yase.combat(houyi)
\ No newline at end of file
class Player(Hero):
def __init__(self,name,hero_type):
super(Player,self).__init__(name)
self.hp =200
self.attack=250
self.hero_type = hero_type
print("英雄"+self.name+"创建成功,类型为:"+self.hero_type)
print("当前等级,血量,攻击力分别为:",self.level,self.hp,self.attack)
sb = Player("sb","刺客")
\ 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