We have learned how to create classes and objects.
Create a new program, test it and
upload it using your name and followed by AS7.1 in the programs file
name. As an example a programs filename could be Name_Surname_AS7.1.py
For your effort you will be graded and you will have another try if you want to get a better grade. Passing grade is 60%
The program should start with three class definitions, then code that will create instances of each class.
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:
- A make_noise() method for Cat that prints ``Meow says [animal name].''
- A constructor for Cat that prints ``A cat has been born.''
A class named Dog:
- 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.
A main program with:
- 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.