Question: Java program Mastermind or Master Mind is a code-breaking game for two players. One player becomes the code- maker, the other the code-breaker. The game

Java program

Mastermind or Master Mind is a code-breaking game for two players. One player becomes the code- maker, the other the code-breaker. The game rules of your program:

  • The code-maker chooses a pattern of four code Letters as a subset of the following 8 alphabetic letters { A, B, C, D, E, F, G }.

  • The code cannot include duplicates and blanks.

  • The chosen pattern is placed in an input file, entered by the code-maker but not known by the code-

    breaker.

  • The code-breaker tries to guess the pattern in the right order in both orders, within twelve turns.

  • Each guess is made by placing a row of code patterns on the decoding board.

  • Once placed, the program provides feedback by placing from zero to four key characters after each

    row of guess. Character Y feedback is placed for each code patters from the guess, which is correct in both character and position. Character X feedback indicates the existence of a correct Character in the code but placed in the wrong position.

  • If the guess of code-breaker is already has been provided in one of the previous steps, the game refers back to the feedback number. The duplicated guess will not be counted.

  • The program print at the end all the guesses

    Hint: Use a 2D array and place the code-maker pattern in the first row. Then all code-breaker guesses in the following rows. Then make simple comparisons. Your program will be a modified version of the

  • Example: If the code-maker input in the file F G B A

  1. Code-breaker Guess: A B C D

  2. Feedback 1: X X

  3. Code-breaker Guess: A B E F

  4. Feedback 2: X X X

  5. Code-breaker Guess: A B E G

  6. Feedback 3: X X X

  7. Code-breaker Guess: A B F G

  8. Feedback 4: X X X X

  9. Code-breaker Guess: B A G F

  10. Feedback 5: X X X X

  11. Code-breaker Guess: A B E G

  12. Repeated guess! Feedback 3: X X X

  13. Code-breaker Guess: G F B A

  14. Feedback 6: Y Y X X

  15. Code-breaker Guess: F G B A

  16. Feedback 7: You win by 7 rounds

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!