Question: Description: In this lab you will build a guessing game using an ArrayCollection. The le Animals.txt contains a long list of animal names, one per
Description: In this lab you will build a guessing game using an ArrayCollection. The le Animals.txt contains a long list of animal names, one per line. You must create an application AnimalGuess that reads that le and creates a collection of animal names (using the ArrayCollec- tion class). Your application should then generate a random character and challenge the user to repeatedly enter an animal name that begins with that character, reading the names entered by the user until they either enter a name that does not begin with the required character or is not in the collection, or they enter a name they used before. Finally, your application reports how many names they successfully entered. Here are a few guidelines for the program: 1. The program should prompt the user for a single random character at the start of the round. The user will guess only animals with that letter as the rst character until they reach one of the failure conditions. 2. You will not want to modify the animal collection during the game. Think of a separate mechanism for tracking what the user has already guessed. 3. The ASCII code for the lowercase letter `a' is 97. To generate random characters, you'll need to cast integers from 97 - 122 as type char 4. There is a method in the String class called toLowerCase() to convert all characters in the String to lowercase. Consult the Java API for instructions on proper use. 5. Recall if you are using a Scanner object with a le instead of System.in, you need to initialize the variable with: Scanner sc = new Scanner(new File("/PATH/TO/FILE/Animals.txt")); 6. Finally, note that ArrayCollection does NOT throw over ow exceptions, so ensure that you create your Collection with a large size or your application will silently fail to read in the rest of the animal list after the rst 100. Once you are nished, submit ONLY the le AnimalGuess.java.
animal.txt
aardvark albatross alligator alpaca ant anteater antelope ape armadillo baboon badger barracuda bat bear beaver bee bird bison boar buffalo butterfly camel caribou cassowary cat caterpillar cattle chamois cheetah chicken chimpanzee chinchilla chough coati cobra cockroach cod cormorant coyote crab crane crocodile crow curlew deer dinosaur dog dogfish dolphin donkey dotterel dove dragonfly duck dugong dunlin eagle echidna eel eland elephant elephant seal elk emu falcon ferret finch fish flamingo fly fox frog gaur gazelle gerbil giant panda giraffe gnat gnu goat goldfinch goosander goose gorilla goshawk grasshopper grouse guanaco guinea fowl guinea pig gull hamster hare hawk hedgehog heron herring hippopotamus hornet horse hummingbird hyena ibex ibis jackal jaguar jay jellyfish kangaroo kinkajou koala komodo dragon kouprey kudu lapwing lark lemur leopard lion llama lobster locust loris louse lyrebird magpie mallard mammoth manatee mandrill mink mole mongoose monkey moose mouse mosquito narwhal newt nightingale octopus okapi opossum ostrich otter owl oyster panther parrot panda partridge peafowl pelican penguin pheasant pig pigeon polar bear pony porcupine porpoise prairie dog quail quelea quetzal rabbit raccoon ram rat raven red deer red panda reindeer rhinoceros rook salamander salmon sand dollar sandpiper sardine sea lion sea urchin seahorse seal shark sheep shrew skunk sloth snail snake spider squirrel starling stegosaurus swan tapir tarsier termite tiger toad turkey turtle vicua wallaby walrus wasp water buffalo weasel whale wolf wolverine wombat wren yak zebra
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
