Question: Goal: Learn to call static methods. Assignment: Continuing the previous question, the final task you work on for the Zoo is to make a system
Goal: Learn to call static methods.
Assignment: Continuing the previous question, the final task you work on for the Zoo is to make a system that keeps track of all the habitats. You are tasked with creating the list of habitats that get created.
Continuing to work on the Habitat class, a static int constant MAXHABITATS has been defined and initialized. Define a public static array of Habitat field habitats. Create a public numberOfHabitats counter to keep track of the number of habitats, too. You are given the code of the constructors as well. Make sure they register the new instances of the Habitat class. Do not modify their visibility modifiers or their parameters. Finally, create a static method printHabitats that prints all habitats to screen.
Make sure the output follows the format of the sample run. For simplicity, convert the surfaceArea to int when printing out the habitat.
Note: Assume the number of created habitats will never exceed MAXHABITATS.
Sample Run
Habitats
Max Population:
Animal Size: Small
Animal Diet: Herbivore
Surface Area: m
Max Population:
Animal Size: Medium
Animal Diet: Omnivore
Surface Area: m
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
