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
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.
1. 구현한 기능 목록
자동차 이름 입력 및 유효성 검사:
getCarNames: 쉼표(,)를 기준으로 자동차 이름을 입력받는다.validateCarNames: 이름이 5자를 초과하거나, 비어있거나, 공백일 경우IllegalArgumentException을 발생시킨다.시도 횟수 입력 및 유효성 검사:
getTryCount: 시도할 횟수를 입력받는다.IllegalArgumentException을 발생시킨다.경주 진행 및 상태 관리:
Car데이터 클래스를 생성하여 자동차의 이름(name)과 위치(position)를 관리했다.runRace,playRound,tryMove함수를 통해 경주를 진행했다.Randoms.pickNumberInRange(0, 9)값이 4 이상일 경우에만 전진(position++)하도록 구현했다.printRoundResult: 매 라운드 종료 시 차수별 실행 결과를 출력했다.최종 우승자 선정 및 출력:
printWinners: 경주가 끝난 후, 가장 많이 전진한(maxPosition) 자동차를 우승자로 선정했다.2. 테스트
기능 구현과 병행하여
ApplicationTest.kt에 테스트 코드를 작성하며 기능을 검증했다.@ParameterizedTest를 활용하여 잘못된 자동차 이름("pobi,javaji",""등)과 잘못된 시도 횟수("a"," ","","0")에 대한 예외 발생을 검증했다.assertRandomNumberInRangeTest를 사용하여 무작위 값을 고정하고,기능 테스트가 의도한 대로(전진/멈춤) 동작하는지 확인했다.