Question: Write a python code that defines A class named Animal: *Add an attribute for the animal name *Add an eat() method for Animal that prints

Write a python code that defines

A class named Animal: *Add an attribute for the animal name *Add an eat() method for Animal that prints "Munch munch." *A make_noise() method for Animal that prints "Grr says [animal name]." *Add a constructor for the Animal class that prints "An animal has been born."

A class named Cat: *Make Animal the parent. *A make_noise() method for Cat that prints "Meow says [animal name]." *A constructor for Cat that prints "A cat has been born." *Modify the constructor so it calls the parent constructor as well.

A class named Dog: *Make Animal the parent. *A make_noise() method for Dog that prints "Bark says [animal name]." *A constructor for Dog that prints "A dog has been born." *Modify the constructor so it calls the parent constructor as well.

Create a test program with: *Code that creates a cat, two dogs, and an animal. *Sets the name for each animal. *Code that calls eat() and makeNoise() for each animal. (Don't forget this!)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!