V
V
Vadim kyklaed2016-12-01 16:08:51
Python
Vadim kyklaed, 2016-12-01 16:08:51

Why is it not inherited?

Hello everyone, everything seems to be done correctly but does not want to work in any way, tell me what is the mistake

class Hero:
  def __init__ (self, hero_name,hero_class):
    self.hero_name = hero_name
    self.hero_class = hero_class

  def info(self):
    print(self.hero_name, self.hero_class)		


class WarriorHero(Hero):
  def __init__(self,hero_name,hero_class):
    super().__init__(hero_name,hero_class)

  def equipmentHero(self):
    self.type_clothing = "heavy"
    self.weapons_hero = "sword"
    self.shield_hero = "yes"

  def healthHero(self):
    self.health_hero = 100

  def printed(self):
    print("""
         name: {0},
         Class character: {1},
         Health: {2}, 
         Weapon: {3},
         Shield: {4},
         Clothing: {5}
         """ .format(self.hero_name, 
         			self.hero_class, 
         			self.health_hero, 
         			self.weapons_hero, 
         			self.shield_hero, 
         			self.type_clothing ))	


b = Hero("kyklaed","warrior")
b.info()
a = WarriorHero("kyklaed","warrior")
a.printed()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-12-01
@kyklaed

def __init__(self, hero_name, hero_class):
        Hero.__init__(self, hero_name, hero_class)

or
def __init__(self, hero_name, hero_class):
        super(WarriorHero, self).__init__(hero_name, hero_class)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question