Overview | Schedule | Resources | Assignments | Home |
In the classic fairy tale "Rumpelstiltskin", a magical creature threatens to take a woman's baby unless she can guess the creature's name. She guesses names unsuccessfully for a while, then overhears that its name is Rumpelstiltskin and wins the challenge (I always considered this a bit of a cheat, and wondered just what the moral of the story was supposed to be, but that's beside the point...).
In this assignment, you will implement a program to play a name guessing game. To help the computer guess a name, after each incorrect guess you will tell it whether the desired name comes before or after the guess in dictionary order. When the program starts, the user can load in a list of common names from a file and store them in a binary search tree. Playing a game is then just following the process of searching the tree, with the twist that it asks the user which way to go from each node. If it finds the player's name in the tree, then the computer wins. If it reaches a point where there are no more possible names, then it gives up -- the user is then asked what name they were thinking of, and it is inserted at the correct position in the tree. In either case, the computer offers to play another round. At the end, the user is given the chance to save the names (including new ones learned while playing) to a file before exiting.
The Guessing project has at least four classes:
The Guessing project:
I:\10607_CSC122\public\Rumpelstiltskin
. In
addition to the Java files for the project skeleton described above, you will find a text file named
2Knames.txt
which has the 2000 most popular baby names from 2005, according to the
U.S. Social Security Administration
(http://www.ssa.gov/OACT/babynames/
);
the names are arranged one per line, in order from most to least popular, so they are ready to
be loaded in when playing the game.writer.println(name);
(that is, you may use
a PrintWriter object in the same way you use System.out
).public
folder, named
RumpelstiltskinDemo.jar
-- it is an executable jar file which should run when double-clicked,
if Java is installed correctly.Standards:
Your project should be well-written, neatly-formatted, modular, and well-documented.
Grading:
Overview | Schedule | Resources | Assignments | Home |
DePauw University,
Computer Science Department,
Fall 2006
Maintained by Brian Howard
(bhoward@depauw.edu
).
Last updated