Question: Make the following changes to the Penguin Rookery from Module 2 : Replace the Species class with an enumerated type. Replace the three Penguin instance

Make the following changes to the Penguin Rookery from Module 2:
Replace the Species class with an enumerated type.
Replace the three Penguin instance variables in the rookery with an array of Penguins.
If you do not already have a default constructor for the PenguinRookery, add one.
Add an overloaded PenguinRookery constructor which accepts an array of Penguins as a
parameter. Name the parameter using the same name as your array instance variable and use
the this reference to assign to the instance variable in the constructor.
Add a toString method to the PenguinRookery which displays the state of the rookery, including
the penguin states and total number of penguins in the rookery.
Change the species instance variable in the Penguin class from int to the enumerated type.
Change any parameters in the Penguin class which use the int type for the species to the
enumerated type.
Add an accessor and mutator to the Penguin species to the Penguin class. Use the this reference
where needed (required in the mutator, optional in the accessor).
Change the toString method in the Penguin class to use the name() method of the enumerated
type.
Change the unit tests (main method) in the PenguinRookery class to instantiate the rookery
object using the overloaded constructor; pass a locally instantiated array of penguins to it.
Add a unit test for the Species mutator and accessor in the main method by modifying the
Penguin array elements species and then redisplaying the values (refer to the practice exercise
solution for an example of how this should be done).
Expected output is as follows:
Our rookery contains the following penguins:
First penguin is a(n) CHINSTRAP.
Second penguin is a(n) GENTOO.
And the final penguin is a ADELIE.
There are a total of 3 penguin species in our rookery.
Testing mutators and accessors
first penguin: ADELIE
second penguin: CHINSTRAP
third penguin: GENTOO
Include all source code in a single source file (PenguinRookery.java).
Be sure your code is indented properly and includes a 4-line ID header.

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!