Background, from http://www.dswilson.com/summer2004/datastructures/assignments/passign1.html

Programming Assignment 1 - The Animal Game

You may pair-program on this assignment. If you work in pairs, you should be working together at the same time, not splitting the work and doing it individually.

Pair-programming promotes greater adherence to other practices, so I will be stricter about test-coverage and code quality for pairs.

The Animal Game is a very old computer learning game that is easily implemented using binary trees. The user picks an animal, then the computer will ask a series of yes/no questions and guess at what animal the player has selected. If the guess is incorrect, the player is asked to provide a yes/no question that would distinguish the animal selected by the player from the one guessed by the computer. Initially the game starts with only one animal (and no questions).

You can try playing this game at http://www.animalgame.com, though to prevent abuse you must register in order to add animals.

Your assignment is to implement this game. Requirements are:

You must have JUnit tests for as much of your code as possible. Try to separate the I/O from the data structure to simplify testing and make the program more flexible.

There are several ways you could save data in a file. One relatively simple approach is to to use a LISP-like notation such as this:

("Does it bark?" ("Does it live in the ocean?" "Seal" "Dog") "Cat")
or, more readably,
("Does it bark?" ("Does it live in the ocean?" "Seal" 
                                               "Dog") 
                 "Cat")
In general, each node would be written as:
(question yes-answer no-answer)
where yes-answer and no-answer may be leaf nodes representing animals or may be internal nodes. Note that the contents of a node are enclosed in parenthesis, and the strings are enclosed in quotes since they may have spaces. To simplify things you may assume that the questions and animal names will not have parenthesis or quotes in them. Writing the tree out in this format is fairly simple, reading back in is more work.

Obviously, this is not the only format in which you could write the tree.

I'd suggest that you first use Java Serialization to read and write the tree and concentrate on getting the rest of the program working. Once you've done that you can worry about using a more user-friendly format for the data.