Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago