subject

Description: You are to create two subclasses of the Animal class (from the previous Animal Class Challenge) that is used to store information about either a mammal or a bird. You are then to extend the Animal Generator program that takes user input, allowing the user to create multiple Mammal or Bird objects. Finally, you are to retrieve the information stored in those objects and display it. Purpose: The purpose of this challenge is to provide experience creating and using subclasses in Python 3.
Requirements:
You are to create two subclasses of the Animal class (from the previous Animal Class Challenge) that is used to store information about either a mammal or a bird. You are then to extend the Animal Generator program that takes user input, allowing the user to create multiple Mammal or Bird objects. Finally, you are to retrieve the information stored in those objects and display it.
The solution from the previous Animal Class Challenge is available as part of the Animal Class Retrospective.
Mammal Class
Write a class named Mammal that inherits from the Animal class that has the following additional attribute and method. This class is to be added to the Animal. py file that was created for the Animal Class Challenge.
Attributes
The following hidden attribute is used to indicate the color of the mammal’s hair.
__hair_color:
Methods
The following method is to initialize the two attributes from the Animal class required in the Animal class’ __init__, the single attribute listed above, and assign their default values.
__init__:
The following method is to return the value of the __hair_color field.
get_hair_color:
Bird Class
Write a class named Bird that inherits from the Animal class that has the following additional attribute and method. This class is to be added to the Animal. py file that was created for the Animal Class Challenge.
Attributes
The following hidden attribute is used to indicate if the bird can fly.
__can_fly:
Methods
The following method is to initialize the two attributes from the Animal class required in the Animal class’ __init__, the single attribute listed above, and assign their default values.
__init__:
The following method is to return the value of the __can_fly field.
get_can_fly:
Animal Generator Program
Once you have written the classes, extend the animalGenerator. py from the Animal Class Challenge. This program is to use Animal. py as a module.
In animalGenerator. py, prompt the user to enter if they would like to create a mammal or a bird.
If the user selects mammal, prompt the user for the name, type of the mammal, and the color of hair. Create a new Mammal object to store this data.
If the user selects bird, prompt the user for the name, type of the bird, and if the bird can fly. Create a new Bird object to store this data.
Finally, ask the user if they would like to repeat the process. They are to be able to create as many Mammal and Bird objects as they like.
After the user is done creating animals, this program is to use the object’s accessor methods to retrieve the name, type, and mood of each animal. This information is to be formatted and displayed as shown in the sample program output below.
Sample Output
Welcome to the animal generator!
This program creates Animal objects
Would you like to create a mammal or bird?
1. Mammal
2. Bird
Which would you like to create? 2
What type of bird would you like to create? Penguin
What is the bird’s name? Peggi
Can the bird fly? Yes
Would you like to add more animals (y/n)? y
Would you like to create a mammal or bird?
1. Mammal
2. Bird
Which would you like to create? 1
What type of mammal would you like to create? Tiger
What is the mammal’s name? Truman
What color is the mammal’s hair? Orange
Would you like to add more animals (y/n)? n
Animal List
Peggi the Penguin 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.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 20:30, kaylee2828
Column a of irma’s spreadsheet contains titles for each row, but her document is too big and will be printed three pages across. she wants to be sure that every page will be understood. what can irma do to with this problem?
Answers: 3
image
Computers and Technology, 24.06.2019 12:00, yagalneedshelp8338
Match the function to its purpose. fast worth 50pts.
Answers: 1
image
Computers and Technology, 24.06.2019 15:00, cooljariel11
What questions about an audience should be asked during presentation preparation? check all that apply. what does the audience already know about the topic? how will multimedia tools inspire the audience? is the information interesting and engaging? how will this information affect the presentation? will the audience change the message’s purpose? what is likely to interest the audience?
Answers: 3
image
Computers and Technology, 25.06.2019 04:20, mjam85877
Many prestigious universities have a system called a “legacy preference system” which is used to decide which applicants should be accepted to the university. if an applicant’s parent is an alumnus of the university, the applicant will be admitted with lower gpa and sat scores than if the parent is not an alumnus. (there is currently a lot of discussion about the fairness of this system, but universities get a lot of money from their alumni so they are unwilling to change ) your assignment for mp2 is to implement a computerized system like this for a very small prestigious university. the university has two schools, liberal arts and music, each with their own criteria for accepting students. your program must read in certain information about an applicant and print a message saying whether the applicant should be accepted or not.
Answers: 2
You know the right answer?
Description: You are to create two subclasses of the Animal class (from the previous Animal Class Ch...

Questions in other subjects:

Konu
Mathematics, 03.02.2020 20:59