Assignment 6 – Animal Guessing Game

Maximum Points = 50

The purpose of this lab is to introduce you to the Tree data structure and storing objects in a file (hint: use Serializable). In this lab you will write a program that manages a self-learning animal guessing game. Your program will ask the user to pick a name of an animal and then ask the user a series of yes-no questions until your program guesses the name of the animal or exhausts the set of questions.

 

1)    Your program will

a)    Read the data from a file animals.dat if it exists and/or,

b)    Start with the question “Does the animal live on land?” [answers are elephant and shark for this first question]

2)    If the user answers yes, then

a)    Either ask the user the next question for land-dwelling animals (e.g is the animal big?), or

b)    If there are no more questions, ask the user if the animal is a “elephant” or the animal from your database at that stage

3)    If the user answers no, then

a)    Either ask the user the next question for water-dwelling animals(e.g Does the animal have scales?), or

b)    If there are no more questions, ask the user if the animal is a “shark” or the animal from your database at that stage

4)    If the program guesses correctly in 2 or 3, provide an appropriate response.

5)    If the program does NOT guess the animal correctly,

a)    ask the user for the name of the animal she(he) was thinking of and a yes-no question that distinguishes the user’s “new” animal and the last animal guessed, and

b)    Replace the animal provided by your program with the question and the two animals

6)     Continue the “game” until the user ends the game.

7)    When the game ends, save the “database” of questions and animals in a file animals.dat.

 

 (Due before class on Thursday, April 9, 2010) Bring a .doc file containing a UML class diagram for ALL the classes used in your program.
(Due on Friday, April 16, 2010 before 5 pm) Submit your .java files containing your program.

 Grades are determined using the following scale:

Grading Rubric  (Word document)