Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phjppo0918 #2

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Phjppo0918 #2

wants to merge 17 commits into from

Conversation

phjppo0918
Copy link
Member

No description provided.

Add new contents to README
- feature list
- exception list
- enum list
Add an enum specifying the following message
- starting game
- guess value input request
- restart request after game is finished
Add message enum needed to show result for guesses
- strike
- ball
- nothing
Add regex enum for input
- 1 or 2 single digit
- 3-digit number from 1 to 9
Add exception handling for user input
- not suitable regex
- overlap number
Validate inputs for
- game restart or not response message
- guess value input message
Add ability to create element
- generate 3 non-overlapping, ordered random numbers
-  generate list of 3 numbers based on user input
add detail features
- compare target and guess values
- determining whether nothing
- return whether out
Outputs console messages to proceed with the game.
Asks for guess value until user exits.
After checking the user's ball count, the game ends when out.
Request whether to restart after playing one game.
The game continues until the end request is made.
Generate unit tests for validating user console input messages.
1. restart request message
- enter strange characters
- enter numbers other than 1 and 2
- enter 2 or more digits
2. guess value input message
- enter strange characters
- input with 0
- duplicate number entry
- enter more than 3 digits
Create unit tests with response messages for the user's predictions.
- unit test for all possible ball count cases
- out if 3 strikes
In the past, it requested to change the argument as it is.
So, if an immutable object is received as an argument, an exception is raised, which can cause problems due to shallow copying even if no exception is raised.
So, change the caller to copy and use the argument.

Before: 

public StrikeAndBallCount(List<Integer> target, List<Integer> guessValue) {
    digitNumber = target.size();
    setStrikeCountAndCheckIfStrike(copyTarget, copyGuessValue);
    setBallCount(copyTarget, copyGuessValue);
}


After:

public StrikeAndBallCount(List<Integer> target, List<Integer> guessValue) {
    List<Integer> copyTarget = new ArrayList<>(target);
    List<Integer> copyGuessValue = new ArrayList<>(guessValue);
    digitNumber = target.size();
    setStrikeCountAndCheckIfStrike(copyTarget, copyGuessValue);
    setBallCount(copyTarget, copyGuessValue);
}
…alues ​​to a first class collection

Changed the random value set and guess value list previously generated by BallGenerator to the first class collection.
DIGIT_NUMBER from BallGenerator moved to GamePlayer class.
Modify StrikeAndBallCount to use the changed first class collection, and change the unit tests accordingly.
…ives the parameter to private

Although the access modifier was provided as public for the unit test, it is okay to change it to private while the unit test creates a mock object.

before : 

public Target(List<Integer> targetValue) {
    this.targetValue = new ArrayList<>(targetValue);
}

after : 

private Target(List<Integer> targetValue) {
    this.targetValue = new ArrayList<>(targetValue);
}
For the ease of testing, the part that generates random values ​​of the target is changed so that the target element can be configured with a random value through a mock object.
Update to reflect created/modified/deleted classes. In addition, access modifier are displayed for each detailed function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant