|CS 173||Introduction to Computer Science II||Spring 2019|
The main goal of this project is to gain more familiarity with iterators.
Starting with the Animals.java class we worked on in class, add an iterator that returns a random animal from this list, but with only one animal per starting letter. In the cases where there is more than one animal per starting letter, randomly select one of those animals. Iterate through all the possible starting letters. For example, there are two animals with a starting letter 'h' ("hen" and "hog") and only one starting with 'y' ("yak"). Thus "yak" will always appear, but "hen" and "hog" will each only appear 50% of the time. Note there are no animals that have a starting letter of "x".
Suggestion: create an alphabetical list of animals with only one animal per starting letter, then randomise that list.
For the set of animals, here is an example alphabetical list:
ape, bee, cod, dog, emu, fox, gar, hen, jay, kea, moa, nag, owl, pig, rat, sow, tom, yak, zho
Your list will be randomized.
Your code should be general enough to work on any alphabetical list, not just the one given.
Include code in a main method that demonstrates your iterator.
Copyright © 2019, David A. Reimann. All rights reserved.