Hey, I have trying to build a large hierarchical tree of all sorts of creatures in Python by using class inheritance. However I seem to have been halted before I can even get anywhere.
I created my first base class:
class Creature(object): def __init__(self): self.hitPoints = 100 self.legs = 1 self.legHitPointsTotal = 3 * self.hitPoints / 10 self.individualLegHP = self.legHitPointsTotal / self.legs self.isDead = bool(False) self.isMobile = bool(True) if self.hitPoints < 1: self.isDead = bool(True)
Then when I try to test this class through the derived class I get this error
Traceback (most recent call last):
File "/myHomeDirectory/NetBeansProjects/creatureLists/src/superTypes/insects/Insects.py", line 4, in <module>
from Creatures import Creature
File "/myHomeDirectory/NetBeansProjects/creatureLists/src/Creatures.py", line 6, in <module>
File "/myHomeDirectory/NetBeansProjects/creatureLists/src/Creatures.py", line 9, in Creature
NameError: name 'false' is not defined
In case it's important, here is the derived class as well:
class Insects(Creature): def __init__(self): Creature(Subclass, self).__init__() self.hitPoints = 80 self.legs = 6 if self.legHitPointsTotal == 0: self.isMobile = bool(False)
I don't even need to try and do anything more that simply running the derived class and it gives me that error. Am I mistaken or is there no 'false' in either class? Please help.