View the step-by-step solution to:

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

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

Sign up to view the entire interaction

Top Answer

Please find attached... View the full answer

Constructors_Assignment_Improved.png

+ Elird #Elird(Stri ng)
#Elirdo +calculateLifeExpectancvo : double + AnimalSet -animals :ArrayList<Animal> +AnimalSet0
+getAnimalsO :ArrayList<Animal>...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online