The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 364 Weeks Ago, 2 Days Ago |
| Questions Answered: | 1850 |
| Tutorials Posted: | 1850 |
Graduate in Biology and Nutrition, MBA Finance
Florida State University
Aug-2000 - Jul-2007
Ass. Relationship Manager
Penn-Florida
Mar-2009 - Feb-2016
Modify the Animal class included in the template file to include two additional methods:
a. setAge() which takes an integer as a parameter and sets the animal's age to the value of the
parameter
b. getAge() which takes no parameters and returns the age of the animal
You should also modify the speak(), __str__, and __repr__ methods to display the animal's age in
addition to the animal's species and language and modify the constructor to take an additional
parameter for the animal's age (as the last parameter), set to 0 if no age is provided. The following file 4.png shows
how the Animal class and its new/modified methods could be used
2.:Implement the function processAnimals() that takes as a parameter the name of an input file. The input
file contains zero or more lines with the format: species, language, age where species is a string
representing an animal's species, language is a string representing an animal's language, and age is an
integer representing an animal's age. The items on each line are separated by commas.
The processAnimals() function should read all lines in the file, creating an Animal object for each line
and placing the object into a list. The function also displays to the screen the result of calling speak() on
each object in the list it created. The function returns the list of objects created or an empty list if the
file didn't contain any lines. Don't forget to close the input file. If your function cannot open the input
file it should display a message to that effect and return an empty list. The information below shows
how you would call the function processAnimals() on an example file. The file empty.txt is empty and
the file none.txt does not exist. Please note that your implementation should work on any file with the
specified format, not just the one provided as a test case:
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- -----------Tha-----------nk -----------you----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m Â----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I