CS 112 Project 7
Mastermind
Part I due Wednesday, April 16, 2008
Part II due Wednesday, April 23, 2008

Mastermind

For your next project, you will implement the game of Mastermind. The rules of the game of Mastermind can be found here.  Mastermind is a single player game, where the computer picks a random code of four colors, and the user tries to guess the code.  After each guess, the computer tells the player how many guesses were the correct color in the correct location, and how many guesses were the correct color in the incorrect location.  For each correct color in the correct location, the computer gives the player a black token, and for each correct color in the incorrect location, the computer gives the player a white token.  For example, if the secret code was:

Blue Black Blue Red

And the player guessed:

Blue Red Red Yellow

Then the computer would respond with:

Black White

Since one color (blue) was in the correct location, and one color (red) was correct, but in the wrong location.

Likewise, if the secret code was:

Yellow Yellow Blue Green

and he player guessed

Red Black Yellow  Blue

Then the computer would respond

White White

Since no color is in the correct location, but two colors (yellow and blue) are correct, but in the wrong locations.

The player has up to eight guesses to try to figure out the secret code.

Part I

For part I of the assignment, you will create a command-line version of Mastermind.  The computer will prompt the user for a guess  and then print the result.   Play continues until the secret code is guessed, or the maximum number of guesses is reached.   When the game is finished, an appropriate message should be printed out


BEFORE YOU START CODING, you need to design your project.  That is, what classes are you going to have, what methods are going to be in each class, and what dependancies there are -- that is, which classes will call other classes methods.

Also for Part I, you need to design the interface for the GUI.  Give a sketch of what the window will look like for your MasterMind GUI, and describe how to interact with the GUI.  I need to approve your GUI before you implement it (of course, you could go ahead and implement it before my approval, but you may have some wasted effort if your design is not approved.

Note that the GUI is harder than the command line version -- you may want to finish up the command line version early, so you have more time to work on the GUI.

Part II

For part II, you need to add a GUI to your Mastermind game, and implement it as an applet.  You have a fairly large amount of leeway here -- as a minimum, you need to:

You can create a board that looks like the the official board (wikipedia link).  You can have the player click on buttons to determine the move, or (if you are really ambitious), drag pieces onto the playing field to implement the moves.  You need to have your design approved for Part I.

Submission

All file(s) required for your project should be in the folder https://www.cs.usfca.edu/svn/<username>/cs112/Project7/