Write 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 ``Grrr 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 that will: Code that creates a cat, two dogs, and an animal. Sets the name for each animal. Code that calls eat() and make_noise() for each animal. (Don't forget this!)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 5PE: Using classes, design an online address book to keep track of the names, addresses, phone numbers,...
icon
Related questions
Question

Use Python Programming Language

Write 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 ``Grrr 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 that will:

  • Code that creates a cat, two dogs, and an animal.
  • Sets the name for each animal.
  • Code that calls eat() and make_noise() for each animal. (Don't forget this!)
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT