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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started