Computer Science 60
Principles of Computer Science
Spring 2005


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

In this assignment you will implement the 20 Questions Game, described in class, using Java. This is a lot of fun but also requires some careful design. There is also a completely optional bonus problem, which will make your 20-questions program considerably more powerful. This assignment is again a step up from the last three, please try to start early!

You will find a 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 by running

  java twenty_questions
so that you get a good feel for how the program should work!

Here are the requirements for your program:

The only slightly "grungy" thing 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 class. If you wish, you may have other files as well. You can use cs60submit multiple times, once for each file that you need to submit. Alternatively, if you type cs60submitall and hit the RETURN key, all of the java files in the directory in which you are currently located will be submitted. cs60submitall will show you the name of each file that it is sumbitting for you. Pretty nifty!

If you play your 20-questions game more than once, you'll notice that there is an important capability missing -- it would be nice if the tree of animals and questions were stored somewhere at the end of the game and read in again the next time you want to play! This is the motivation behind this week's extra credit problem:

Last modified February 2005 by Ran Libeskind-Hadas or Z Dodds