CS 0007 – Project 4: Mastermind

Due: Friday, March 25th 2005

 

Your fourth project is to implement the game of Mastermind. In this game, the computer chooses 4 pegs each with one of 6 colors.  The player’s job is then to guess the colors that the computer has chosen in the proper order. After each guess by the player, the computer will then give two numbers as feedback.  The first number is how many pegs are the proper color and in the proper position. The second number is how many pegs are the proper color, but not in the correct position.

 

What you need to do:

 

 

Example:

 

Welcome to Mastermind!

Would you like to play? yes

 

Enter guess number 1:

rrrr

Colors in the correct place: 1

Colors correct but in wrong position: 0

 

Enter guess number 2:

 

Hints:

 

 

String input = Console.in.readLine();

for(int i=0; i<input.length(); i++) {

// get the ith character out of the string.

     char c = input.charAt(i);

// do some checking

}