I'm going through 'Learning Python The Hard Way', and I got to the class lesson. I understood it (or I at least think I did!) and tried to create a simple variation, using my own names, functions, etc...
Now the problem I'm having is that the code won't return anything in command line\powershell. It doesn't have any errors, it just goes to another line of input.
Here's the Code:
class Animal(object):
'''represents any animal'''
def __init__(self, legs, size):
self.legs = legs
self.size = size
def detail_animal(self):
'''show # of legs and size'''
print "Name: %r\nAge: %r" % (self.legs, self.size)
class canine(Animal):
'''represents a canine'''
def __init__(self, legs, size, hair_length):
Animal.__init__(self, legs, size)
self.hair_length = hair_length
def detail_canine(self):
Animal.detail(self)
print 'Has %r inch long hairs.' % self.hair_length
class feral_cat(Animal):
'''represents a feral cat'''
def __init__(self, legs, size, tail_length):
Animal.__init__(self, legs, size)
self.tail_length = tail_length
def detail_feral(self):
Animal.detail(self)
print "Tail Length: %r" % tail_length
c1 = canine(4, 2, 0.5)
c2 = canine(5, 3, 0.75)
fc1 = feral_cat(4, 5, 3)
a = Animal(4, 2)
Thanks in advance!
sizefor the age is fine as long as you assume that all animals grow at a linear rate throughout their lifetimes.