1. Draw an object hierarchy diagram for various kinds of people.
2. Declare a new class called Plant, extended from Organism with one extra method:
Suppose fern is a plant. Activating fern.NibbledOn(m) corresponds to some beast eating m ounces of fern. Notice that NibbledOn differs from the existing alterSize method, since in the NibbledOn method the amount is removed from the size (rather than adding to the size), and there is also a strict precondition on the amount eaten. The nibbledOn implementation should activate alterSize to do some of its work.
Your Plant class should have one constructor with the same parameters as the Organism constructor. The plant’s constructor merely activates the super constructor with these same parameters.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here