CSC 533: Organization of Programming Languages
Spring 2007

HW1: Java Programming

Design and implement a Java program that uses a classification tree to identify an object or situation. In the abstract, a classification tree is a binary tree in which the leaves represent possible classifications and the internal nodes represent questions that can be used to distinguish among those classifications. For example, the following simple classification tree might be used to identify objects in a 20-questions type game:

This classification tree can distinguish between five different objects. The initial question is stored at the root: Is it an animal? If the user answers "no," then the link at the right (labeled "n") is followed and the classification "ROCK" is determined. If the user answers "yes," however, the left link (labeled "y") is followed and another question is encountered to further distinguish among the options. Eventually, the answers provided by the users to the questions will classify the object.

Note that a classification tree is a very general-purpose structure. It can be used to identify objects, to diagnose an illness given the patient's symptoms, or to assign a grade to a homework based on a series of tests.

Your program will need to be able to read a classification tree from a file, store that tree in some internal structure, and then repeatedly prompt the user with questions until the final classification is made. For example, given the above classification tree, a dialog with the user might look like the following:

Is it an animal? (y/n) y Does it have fur? (y/n) n Can it fly? (y/n) y Classification: BIRD

The format of the file is up to you, but it should be clearly organized so that files representing other classification trees could be used.