Infotc 1040 introduction to problem solving and

InfoTc 1040 Introduction to Problem Solving and Programming Animal Class 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 object’s accessor methods to retrieve the name, type, and mood of each animal.

 

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 animal’s type. For example: gecko, walrus, tiger, etc. __name: a hidden attribute used to indicate the animal’s name.

__mood: a hidden attribute used to indicate the animal’s 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.

 

 

"Get 15% discount on your first 3 orders with us"
Use the following coupon
"FIRST15"

Order Now