In this project you will implement the 20 Questions Game described in class using Java. This is a lot of fun but also requires some careful design. Please start early!
You will find the compiled version of my solution to this assignment in a file called twenty_questions.class in the directory /cs/cs60/assignments/assignment3. Note that Node.class is the compiled version of Node.java, which in my solution is the class describing a single node in the binary tree. Play this game to make sure that you understand how your program should work.
Here are the requirements for your program:
Think about the design of your code before starting to program. Break up the problem into small logical chunks and make sure that your methods are short and elegant. Also remember to avoid the use of "magic values" in your code. Finally, remember to document your code by providing a header with your name, file name, and date and a description of what the file does. In addition, have at least one line (and ideally even more) of explanation for each method in your code.
Please submit all of the files that comprise your implementation of this game. Undoubtedly, you will have a file describing a node in the binary tree as well as the executable program. If you wish, you can have other files as well. You can use cs60submit multiple times, once for each file that you need to submit.
For Optional Double Bonus Credit write another version of this game called Bonus.java which allows the user to save the binary tree in a file before quitting the game. When the game starts, the program asks if the user would like to load in a file that was saved earlier and, if so, prompts the user for the name of the file. When the game ends, the program asks the user if the game should be saved to a file and, if so, prompts the user for the name of the file. Note that we haven't talked about file input and output in class. Take a look at the java documentation available on the course web page. Part of the objective of this bonus problem is to figure out how file input and output work. You can, of course, use the IO.java code in any way you like.
Last modified September 2003 by Ran Libeskind-Hadas