A game of guessing numbers. The game has four grids, each grid has a number from 0 to 9, and the numbers of any two grids are different. You have 6 chances of guessing, if you guess correctly, you win, otherwise you lose. Each time you guess, you need to enter 4 numbers in sequence. The program will give feedback from xAxB based on the guessing situation. The numbers before A represent the number of positions and numbers, and the numbers before B represent the number of numbers with the right numbers but the wrong positions.
For example: the answer is 1 2 3 4, then for different inputs, there are the following outputs
Example :
The answer is 1 2 3 4, so for different inputs, there are the following outputs
Input Output Instruction
1 5 6 7 1A0B 1 correct
2 4 7 8 0A2B 2 and 4 wrong position
0 3 2 4 1A2B 4 correct,2 and 3 wrong position
5 6 7 8 0A0B all wrong
4 3 2 1 0A4B 4 numbers position wrong
1 2 3 4 4A0B win, all correct
1 1 2 3 Wrong Input,Input again
1 2 Wrong Input,Input again
The answer is generated randomly at the beginning of the game. There are only 6 chances to enter. At each guess, the program should give the results of the current guess, as well as all the previous guesses and the results for the player's reference. The input interface is a console (Console) to avoid too much interface code that is not related to the problem. When entering, separate the numbers with spaces.
Require:
Main.java file under src/main directory in the projectGuess Number Game, You have 6 chances to guess! appears, indicating that the project starts successfullysrc/test directory in the project ./gradlew clean test in the root directory to view the test results