diff --git a/code b/code new file mode 100644 index 00000000..ce68823b --- /dev/null +++ b/code @@ -0,0 +1,87 @@ + +class Animal: + def __init__(self, name, sound): + self._name = name + self._sound = sound + + def makeSound(self): + print("Hello") + + +class Dog(Animal): + def __init__(self): + super().__init__("Dog", "Bark") + +lassy = Dog() +lassy.makeSound() + + +class Duck(Animal): + def __init__(self): + super().__init__("Duck", "Quack") + +class Seal(Animal): + def __init__(self): + super().__init__("Seal", "Screech") + +goofy = Dog() +goofy.makeSound() +daffy = Duck() +daffy.makeSound +salty = Seal() +salty.makeSound + +# polymorphism +animals = [] + +animals.append(goofy) +animals.append(daffy) +animals.append(salty) + +for animal in animals: + animal.makeSound() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file