Question: Hi, please code a java program that is similar to the game mastermind. The game is played between two players. One of them is the

Hi, please code a java program that is similar to the game "mastermind".
The game is played between two players. One of them is the code maker, and the other is the code breaker. The code maker creates a six digit number, where leading zeros are allowed, as opposed to the usual convention. For example, the code could be:
074311
The code is not known to the code breaker. The code breaker then comes up with a guess, and suppose they produce the number:
111000
Now, the code maker compares the guess and the actual code, and provides feedback. The feedback consists of two numbers: The first indicates "direct hits", that is, correct digits in the correct position. The second number is "indirect hits", that is, digits that are in the code, but are in the wrong position in the guess. For this example guess, the feedback would be:
0, 3
There are no direct hits, that is, no digits match exactly between the code and the guess. There is a zero in the wrong place, and there are two ones in the wrong place. That makes a total of three indirect hits.
The code breaker tries to take advantage of the information from the feedback, and produces another guess:
223344
Now the feedback is:
1, 1
This is because the 3 is a direct hit, and there is an indirect hit for 4. The game ends when the feedback is:
6,0

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!