-
Notifications
You must be signed in to change notification settings - Fork 212
[자동차 경주] 이태호 미션 제출합니다. #209
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
Open
lth-1026
wants to merge
14
commits into
woowacourse-precourse:main
Choose a base branch
from
lth-1026:th20001026
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add Car class - Implemented private fields (#name, #totalDistance) - Added getter methods for encapsulated access - Implemented showDistance() method - Created unit tests for Car class
Add input validation for car name entry
- Added empty input check to prevent blank values
- Applied regex /^([^,]{1,5})(,([^,]{1,5}))*$/ to ensure each name is 1–5 chars
Changed structure to include a Race object to better represent relationships between objects in the program
- Integrated getInput logic directly into registerCars - Simplified structure by removing the private getInput method
- Added splitInput function that splits input string by comma - Throws an error if any of the split results is an empty
- Added registerCars method to handle car name registration - Reads input from console using getInput() - Splits input by comma and validates for empty or duplicate names - Stores validated car names in #cars property
- Added maxStop property initialized in constructor - Implemented setStop method to receive stop value from user - Ensured stop cannot exceed maxStop
- Modified registerCars to instantiate Car objects instead of storing name strings - Each car is now created via the Car class during registration - Improved data consistency and encapsulation within the Race class
- Added forwardAttepmt method to attempt car movement - Calls isPossibleForward() to check if the car can move - Executes forward() when movement condition is met
- Implemented start() to initiate the race process - Uses runRound() to perform each round of car movements - Calls showRoundResult() to display each round's result
- Implemented showWinner() to display the final winner(s) of the race - Calls findMaxDistance() to determine the highest total distance - Uses getWinners() to retrieve cars matching the maximum distance - Prints the winner names in formatted output
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.