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, 6 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
Hello this assignment is from last week that you helped me with. This is the feedback my professor provided me. Can you please first incorporate the changes recommended from my professor’s feedback? After the changes are made can you then Introduce Polymorphism where it’s appropriate. Thank you!!
Â
Please indicate public, protected, default or private access modifiers for each of the member variables and methods.
You already have the 'name' attribute in Animal that is accessible from all of its descendants. You should not have it again in Bird, Mammal, and Reptile classes.
Regarding constructors, you have to think from the business (or requirements) perspective if you can create an entry for an animal without a name and without a birthdate. For instance, someone brings a lion to you. Can you register it in your system without a name and without knowing when it was born? Would the system, without knowing this information work properly? In our case, no, because it would not know how to compute life expectancy.
So, you should not have default constructors for Hawk, Eagle, etc. and you should have birthdate included in the non-default constructor.
Â
Next, the way you have shown Animal, Bird, Mammal, Reptile constructors, it means you can instantiate them as these objects. Someone brings a creature and tells you that it is an animal, if you create a record for it, would our system work properly? No, because we can only compute life expectancy for Hawk, Eagle, etc. Additionally, this is beyond the requirements and we should not provide a solution that the requirements do not require. For these classes you should have the constructors as protected and for Hawk, Eagle, etc. you should have them as public. This would ensure that base classes cannot be instantiated and concrete class can be instantiated
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