1. Let’s say you want to assign a number as well as a name to each species
in the world, perhaps to make it easier to catalog them. Modify the
definition of the class SpeciesFirstTry in Listing 5.3 so that it allows for
a number. The number is to be of type int. (Hint:
You mostly just have to
add stuff.)
2. Suppose every species in the world has a peculiar birthing pattern. After
a female is born, a male is born, then a female, and so on. Give the
definition of a method, called getFemalePopulation, that you could add
to the definition of the class SpeciesFirstTry in Listing 5.3 to return
the number of females in the population. Also, give the definition of a
method called getMalePopulation that similarly returns the number of
males in the population. If the population is an odd number, you have
one species member left over after pairing males and females. Assume
that species member is a female. For example, if the population is 7, there
are 3 males and 4 females. But if the population is 8, there are 4 males
and 4 females. (Hint:
The definitions are very short.)