Computer Science 60
Principles of Computer Science
Spring 2004


Assignment 3: Twenty Questions!
Due Monday, February 9 by 11:59 PM

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 our 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 our 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:

The only "grungy" aspect of this project is that of getting input from the user. To demonstrate how input works in Java, we have provided a small demonstration program called IO.java in the directory /cs/cs60/assignments/assignment3. You may use any and all of this code in your own code.

Think about the design of your code before starting to program. We will be grading this program for both functionality and good style. Regarding style, keep the following in mind:

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 Bonus Credit (15 Points) 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 January 2004 by Ran Libeskind-Hadas