-
Notifications
You must be signed in to change notification settings - Fork 92
[자동차 경주] 이상현 미션 제출합니다. #120
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
base: idealhyun
Are you sure you want to change the base?
Conversation
- util 형태로 생성
- 게임 시작 메소드 - 라운드 만큼 시행 - Car 리스트로부터 가장 큰 distance 값 받아오기 - 가장 큰 distance를 기준으로 같은 값을 가진 Car들을 우승자로 정하기
- 랜덤한 값 테스트를 위한 인터페이스 생성
- 자동차 이름 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.
첫 번째 제출 수고하셨습니다!
몇몇 부분들에 대해서 코멘트 남겼어요.
주어진 컨벤션 룰과 4단계 내용에 조금 더 집중해보면 좋을 것 같아요.
만약에 주어진 상황에서 출력이 콘솔이 아닌 gui가 된다면? 또는 웹 응답이 된다면? 어디가 바뀌어야 하고 얼만큼 영향을 받을지 생각해보면 더 도움이 될것 같습니다.
리뷰 남긴부분에 대한 답변 부탁드리고 궁금한 부분들 계속 물어봐주세요!
@@ -14,6 +14,8 @@ dependencies { | |||
testImplementation platform('org.assertj:assertj-bom:3.25.1') | |||
testImplementation('org.junit.jupiter:junit-jupiter') | |||
testImplementation('org.assertj:assertj-core') | |||
testImplementation('org.mockito:mockito-core:5.11.0') |
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.
오 mockito를 쓰셨군요...
@@ -0,0 +1,5 @@ | |||
package domain; | |||
|
|||
public interface NumberGenerator { |
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.
NumberGenerator라는 Interface를 만들었군요 혹시 이 Interface는 어떻게 쓰이나요?
@ExtendWith(MockitoExtension.class) | ||
public class CarRaceTest { | ||
@Mock | ||
NumberGenerator randomNumberGenerator; |
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.
@mock 어노테이션은 어떤역할을 하나요?
import java.util.Random; | ||
|
||
public class RandomNumberGenerator implements NumberGenerator { | ||
private final int MAX_RANDOM_NUMBER = 10; |
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.
위의 값들은 static을 안 썼고, 아래 Random은 static을 썼군요. 어떤 차이가 있나요?
그리고 자바에서 static이 붙고 안붙는게 변수이름에 어떤식으로 적용이 될까요?
(참고 자료 : 구글 자바 네이밍 컨벤션)
} | ||
|
||
private void validate(String name) { | ||
if(name.length() > MAX_CAR_NAME_LENGTH ){ |
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.
discord에서 이야기했던 것처럼 포맷팅을 한번 해보면 좋을 것 같아요.
xml을 등록하고 reformat code를 하면 알아서 다 바뀐답니당
} | ||
} | ||
|
||
private void recordOutput(Car car) { |
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.
요것도 출력과 관련있는 내용인 것 같아요. 만약에, 저희가 gui를 제공하도록 바뀌어야한다고 하면 어디가 영향을 받을까요?
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class CarNameParser { |
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.
CarNameparser는 어떤 의도로 만들었고, 지금상황에서 필요할까요?
import java.util.List; | ||
|
||
public class CarNameParser { | ||
private final String DELIMITER=","; |
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.
이 값이 불변이라면 다른 방식으로 표현해보면 어떨까요??
static을 붙인 변수와 붙이지 않은 변수는 실제로 어떤 차이가 있나요?
@DisplayName("게임 라운드 정수 입력 테스트: 예외 발생") | ||
void invalidInputGameRounds(String input) { | ||
// Given | ||
System.setIn(new ByteArrayInputStream((input + "\n").getBytes())); |
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.
InputViewTest를 해보셨군요. 해보니까 view를 테스트하는건 어떘나요?
|
||
@Nested | ||
@DisplayName("자동차 생성 - 이름 테스트") | ||
class InvalidCarNameTest { |
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.
Nested를 잘 나눠주신것 좋습니다.
자동차 경주 - 초간단 애플리케이션
학습 내용
코드 설명
회고