The GameKeeper class needs a second instance method called findEcoDiversity(int y) which takes an integer argument and returns a set of strings.
The method should iterate over each of the keys in animalMap. In each case where the number of strings in the corresponding value is greater than the threshold value indicated by the integer argument to the method, a message should be printed to the standard output as follows:
Area code X has more than Y kinds of animals
(where X and Y are filled in appropriately)
Finally, the method should return as message reply the last set of strings found (where the number of strings is greater than the threshold) or an empty list, if none were found.
solution
public HashSet <String> findEcoDiversity(int y)
{
// addAnimalEntry();
HashSet<String> ret = new HashSet<String>();
for(Character Key: animalMap.keySet())
{
if(animalMap.get(Key).size() > y)
{
System.out.println(" Area code " + Key + " has more than " + y + " animals ");
ret = animalMap.get(Key);
}
}
return ret;
}