[problem description]
Design and implement a guess Numbers game system, the system records the user name and the process of playing games, exit system show related information, such as:
Joe Smith, you played five innings guess Numbers game, 3 win 2 defeats,
[game]
(1) computer randomly generated four-digit (each 0-9, and each other is not the same).
(2) prompt the user for four don't repeat Numbers;
Position (3) when the user input of Numbers and number are all correct, said;
(4) when the user input number is correct, but the location is not correct, to say;
(5) if user still not guess guess eight times, the game ends,
As just one example to illustrate the rules: assume that the answer is 0359, and the user guess is 0245, shows the feedback "1 a1b", because of the '0' Numbers and position are correct, the reason is shown as 1 a, and the number of '5' right, location is not correct, so the display to 1 b,
[basic requirements]
The system has the following functions:
Answer randomly generated by computer, and must be four digits each are not identical, for example: can't generate 1383 such mystery, because the Numbers' 3 'repeated twice,
The interaction with the user interface for the character menu, game programs are often interactive, almost no non interactive games, this is, of course, because it needs to read the game the player's input and give feedback,
The situation of illegal input can give error messages, once found a mistake, allow the termination procedure,
[the test cases]
Assume that computer generated the answer is 1358, and the user's all input the following marked (underscore) :
The first guess: 1426
Feedback: 1 a0b
Second guess: 3426
Feedback: 0 a1b
Third time: 1530
Feedback: 1 a2b
Fourth speculation: 1573
Feedback: 1 a2b
Fifth: 1538
Feedback: 2 a2b
Sixth speculation: 1358
Ha! Ha! Right, you're great!
On the contrary, if guess eight times still not in, reports that answer to a riddle,
According to realize the function of the score, score method is as follows:
To realize function score
The existence of a randomly generated 6
Mystery control 4
Right and wrong judgment 10
Eight times the answer control 10
The answer clues 4
Overall statistics 6
CodePudding user response:
18913835517 links, canCodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html