Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions