Question
Could anyone please help with this Python 3.6.2 program? In this programming assignment, you are going to create a class named Animal that is used
Could anyone please help with this Python 3.6.2 program?
In this programming assignment, you are going to create a class named Animal that is used to store information about an animal. You will then create a program that takes user input, allowing the user to create multiple Animal objects. Finally, you will retrieve the information stored in those objects and display it.
Animal Class
Write a class named Animal that has the following attributes and methods. Save this class as Animal.py
Attributes
__animal_type
a hidden attribute used to indicate the animals type. For example: gecko, walrus, tiger, etc.
__name
a hidden attribute used to indicate the animals name.
__mood
a hidden attribute used to indicate the animals mood. For example: happy, hungry, or sleepy.
Methods
__init__
this method should create the three attributes above and assign their default values.
The value of __mood should be set randomly. Generate a random number between 1 and 3. Then:
If the number is 1, the __mood field should be set to a value of happy. If the number is 2, the __mood field should be set to a value of hungry. If the number is 3, the __mood field should be set to a value of sleepy.
get_animal_type
this method should return the value of the __animal_type field.
get_name
this method should return the value of the __name field.
check_mood
this method should return the value of the __mood field.
Animal Generator Program
Once you have written the Animal class, create another program called animalGenerator.py. This program should use Animal.py as a module.
In animalGenerator.py, prompt the user to enter the name and type of an animal. Create a new Animal object to store this data. Then ask the user if they would like to repeat the process. They should be able to create as many Animal objects as they would like.
After the user is done creating animals, this program should use the objects accessor methods to retrieve the name, type, and mood of each animal. This information should be formatted and displayed as shown in the sample program output below.
Sample Output
(Input is highlighted in orange)
Welcome to the animal generator! This program creates Animal objects What type of animal would you like to create? Gecko What is the animal's name? Gordon Would you like to add more animals (y/n)? y What type of animal would you like to create? Walrus What is the animal's name? Wally Would you like to add more animals (y/n)? y What type of animal would you like to create? Tiger What is the animal's name? Truman Would you like to add more animals (y/n)? n Animal List ----------- Gordon the Gecko is hungry Wally the Walrus is sleepy Truman the Tiger is hungry
Testing
Run the program you write and verify that the information entered matches the information displayed and that the input prompts and output utilize the format specification provided.
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