OOP Animals

Let's start with a simple assignment to practice your Inheritance skills.

The objective of this assignment is to create two subclasses of Animal named Cat and Dog. Every Animal will be created by passing a name, regardless of the type of Animal. For example:

garfield = Cat(name='Garfield')
odie = Dog(name='Odie')

print(  # 'Garfield'
print(      # 'Odie'

Every animal will have the ability to emit a sound, or as we'll friendly say it, every animal will be able to talk. That's why the Animal class has a talk method which is not implemented. All Animal subclasses will have to properly implement the talk method. This method is really simple and it just needs to return a string. A Cat "meow"s and a Dog "woof"s. Example:  # 'meow'      # 'woof'

Test Cases

test dog barks - Run Test

def test_dog_barks():
    odie = Dog(name='Odie')
    assert == 'woof'

test cat meows - Run Test

def test_cat_meows():
    garfield = Cat(name='Garfield')
    assert == 'meow'

test create animals - Run Test

def test_create_animals():
    garfield = Cat(name='Garfield')
    odie = Dog(name='Odie')

    assert == 'Garfield'
    assert == 'Odie'