Write a program that plays the game MasterMind. The program should create a list of 4 color; the available colors are (R)ed, (G)reen, (P)urple, (Y)ellow, (B)lack and (W)hite. The player must then guess your colors in the correct sequence; validate the list of colors entered. For each correct color guess in the correct position, display a black peg (just 'B'). For each correct color guess not in the correct position, display a white peg (just 'W'). Give the player 12 tries to guess your colors. If the player recieves 4 Black pegs, display a win message. If guess counter reaches 12, display a lose message and display your colors. See an example of the running program below. Functions should be used to create the initial color list, validate the entered list of colors and return guess matches. Include an SDM for the program and any other appropriate documentation.
Output:
Lets play MasterMind!
I am thinking of a series of 4 colors. You have 12 tries to guess the correct
colors in the correct order. After each of your guesses, I will display a B for
each guess correct color in the correct order and a W for each guess correct color
in the wrong order. The available colors are (R)ed, (G)reen, (P)urple, (Y)ellow,
(B)lack and (W)hite. Use only the first character of the color when guessing
(i.e. - RYBG). Duplicate colors are allowed (i.e. - BYGB).
There's no set number of functions, you could probably code that all without using a single function, though you will probably have a lot of duplicate code then. Not to mention a giant pile of mess.
You might want to use 500, you might want to use 2. Those numbers are a bit extreme for your project, but you get the picture. It's all up to how you want to design the program, and how you want it to work.