Question: CS 0007 Programming Assignment 3 Mastermind DUE DATE: Friday, March 25 at 11:59 PM In the game of Mastermind, one player creates a code 4



CS 0007 Programming Assignment 3 Mastermind DUE DATE: Friday, March 25 at 11:59 PM In the game of Mastermind, one player creates a code 4 colors long out of 6 possible colors (red, orange, yellow, green, blue, or white). The other player tries to guess the code in as few attempts as possible. For each incorrect guess, the player who created the code assigns red pegs and white pegs to the guess. A red peg means that the guess has a correct color in the correct spot, while a white peg means that the guess has a correct color in the incorrect spot. The total number of pegs for each guess cannot be more than 4 (the length of a code). Below are a few examples: Code: RYWB Guess: BWYR 0 red pegs, 4 white pegs Code: RRRR Guess: OYBG 0 red pegs, 0 white pegs Code: RGWO Guess: RYBG 1 red peg, 1 white peg Code: 00BY Guess: OGBY 3 red pegs, 0 white pegs Problem Write a program that allows you to play Mastermind against the computer. The computer should generate a random code (a String made up of the characters R, O, Y, G, B, and W, representing the possible colors) and you (the user) will guess it. For each guess that isn't correct, the program should return the number of red pegs and the number of white pegs for the guess. You shoud be able to keep guessing until you win. To complete this assignment, you need to download the Mastermind.java file (attached to Assignment 3 on Coursweb) and add the required methods. You should not have to modify the main method. Remember to document each of your methods appropriately Read the main method carefully to see how the methods work together, and then work through writing each method individually
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
