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 MAX_HABITATS 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 MAX_HABITATS.
Sample Run
Habitats
---
Max Population: 18
Animal Size: Small
Animal Diet: Herbivore
Surface Area: 3600m2
---
Max Population: 2
Animal Size: Medium
Animal Diet: Omnivore
Surface Area: 100000m2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!