-
Notifications
You must be signed in to change notification settings - Fork 108
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
[자동차 경주] 이서현 미션 제출합니다. #111
base: main
Are you sure you want to change the base?
Conversation
자동차 경주 게임의 요구 사항 및 기능 명세 문서 작성
'자동차는 두 대 이상이어야 한다'라는 조건 차고지에서 입력으로 이동
사용자로부터 경주할 자동차들의 이름들을 담은 문자열을 입력받을 수 있는 기능 구현
사용자로부터 시도 횟수를 입력받을 수 있는 기능 구현
사용자로부터 입력받은 문자열이 형식에 맞게 입력된 두 대 이상의 자동차가 맞는지 유효성 검증 test(Input): 입력 문자열 유효성 검증 기능 테스트 구현 입력 문자열 유효성 검증 테스트 구현 및 통과
누락됐던 입력 시 출력 기능 명세 체크 업데이트
테스트 함수명을 기능 명세와 동일하게 변경
사용자로부터 입력받은 문자열을 쉼표(,)를 기준으로 분리하여 자동차 이름 목록 추출 test(Input): 이름 분리 기능 테스트 구현 이름 분리 테스트 구현 및 통과
차고지의 불필요한 기능인 자동차 대수 세기 삭제
각 자동차마다 이름을 부여하는 기능 테스트 구현 및 통과
자동차 이름 설정 시 유효한 이름이 아니면 `IllegalArgumentException` 발생시키는 기능 구현 test($Car): 자동차 이름 유효성 검증 기능 테스트 자동차 이름 유효성 기능 테스트 구현 및 통과
$ApplicationTest 테스트 코드 형식에 따라 테스트 코드 수정
$ApplicationTest 테스트 코드 형식에 따라 테스트 코드 수정
$ApplicationTest 테스트 코드 형식에 따라 테스트 코드 수정
각 자동차가 경주 동안 본인의 위치를 가지는 기능 구현 test($CarTest): 자동차 위치 보유 기능 테스트 자동차 위치 보유 기능 테스트 구현 및 통과
전진 조건에 부합할 때 자동차가 전진하는 기능 구현 test($CarTest): 전진 기능 테스트 전진 조건에 따른 전진 기능 테스트 구현 및 통과
'경주'라는 단어 더 명확하게 수정
0부터 9 사이의 랜덤 수를 만들어내는 기능 구현
랜덤 수가 4 이상일 때 전진하는 기능 구현 test($RaceTest): 시도 횟수만큼 전진 기능 테스트 랜덤 수가 4 이상일 때 전진하는 기능 테스트 구현 및 통과
출력 기능 맞는 위치로 기능 명세 수정
각 시도마다 경주 상황 출력하는 기능 구현
최종 우승자를 선정하는 기능 구현 test($RaceTest): 우승자 선정 기능 테스트 우승자 선정 기능 테스트 구현 및 통과
다중 우승자 선발 기능과 출력 기능 명세 분리 작성
다중 우승자 기능 테스트 구현 및 통과
최종 우승자 출력 기능 구현
시도 횟수 입력 단계에서 유효성 검증할 수 있도록 위치 수정
시도 횟수가 양의 정수인지 확인하는 기능 구현
더 가시적인 예외 처리 위해 해당 오브젝트 별도 구현
컨트롤러로 앱 전체 구현
코드 포맷이 지켜지지 않은 코드 수정
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2주차도 수고 많으셨습니다. 남은 기간도 같이 화이팅해요!!
시간 괜찮으시면 제 코드도 한번 리뷰 부탁드려요.
링크
println() | ||
outputView.printRoundMessage() | ||
repeat(tryCounts) { | ||
race.playOneRound(randomNumberGenerator) | ||
outputView.printCurrentRound(carsInGarage) | ||
println() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MVC 패턴을 사용하셔서 입출력에 관해서는 View에 책임을 부여하신 것 같아요. 그렇다면 RaceManager에서는 출력과 관련된 기능은 View로 분리 시키는 게 더 좋을 것 같아요!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안그래도 개행 고민 중이었는데 분리하려면 확실히 하는 게 낫겠네요 감사합니다!
@@ -0,0 +1,7 @@ | |||
package racingcar.Model | |||
|
|||
object Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 오브젝트는 비즈니스 로직과 밀접한 데이터의 개념은 아니니 모델로 분리하는 게 아니라 유틸리티로 분리하는게 좋을 것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 고민했었는데 유틸 분리 방법이 있군요!
|
||
class Car(val name: String) { | ||
init { | ||
require(name.length <= 5) { name + CANT_BE_LONGER_THAN_5 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
차의 이름이 빈칸("")인 경우의 예외 처리가 필요할 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 그 생각은 못했네요!!
val carsInGarage: List<Car> = nameOfCars.split(CAR_NAME_SPLIT_POINT) | ||
.map { name -> Car(name.trim()) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
차량의 이름이 서로 같으면 안된다는 문제의 요구사항 명세가 있었는데 그 부분에 대한 구현이 아마 안된 것 같아요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헉 저 그 명세는 못봤었는데 그 예외도 있네요 이번주차에는 예외 사항 더 고민해봐야겠습니다!ㅎㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오늘 내로 맞리뷰 달아두겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저번주에 리뷰 링크 달라고 하셨는데 보여드리기 너무 아쉬운 코드여서 못 남겨드렸습니다 ㅜ
이번주 코드는 시간 나시면 리뷰 부탁드려요!
woowacourse-precourse/kotlin-calculator-7#24
override fun generateRandomNumber(): Int { | ||
return Randoms.pickNumberInRange(MIN_NUMBER, MAX_NUMBER) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
랜덤 함수 하나도 유지보수와 확장에 신경쓰신 것 같아요.
하나 배워갑니다!
val regex = Regex(".+,.+") | ||
return regex.containsMatchIn(nameOfCar) | ||
} else | ||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아마 깜빡하신 것 같지만 여기 else만 {}가 안 붙어있어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와 대박 이걸 몰랐네요 감사합니다!
class Garage(nameOfCars: String) { | ||
val carsInGarage: List<Car> = nameOfCars.split(CAR_NAME_SPLIT_POINT) | ||
.map { name -> Car(name.trim()) } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
차고라는 클래스명 센스 있네요.
trim으로 예외가 발생하지 않도록 처리하신 것도 좋은 것 같아요.
No description provided.