Skip to content

Conversation

@jaechu12
Copy link

No description provided.

Copy link

@DHkimgit DHkimgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

과제 진행하느라 고생 많으셨습니다. 고민을 많이 하신 것 같아요. 몇가지 피드백 드렸으니 참고해주세요!

Comment on lines +1 to +15
자동차 이름을 입력

입력받은 문장 쪼개기

예외처리

게임 횟수 입력

게임 진행 출력 및 랜덤 계산

우승자 찾기

우승자 출력

Test추가

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기능 정리하고 각 기능 단위로 커밋 해주셨군요! 좋습니다!!
커밋 메시지 관련해서 깃허브 커밋 메시지 컨벤션 키워드 더 공부해보시면 좋을 것 같아요.
코인 프로젝트의 커밋 메시지를 참고해보세요!

Comment on lines +15 to +22
@Test
void test() {
String input = "1,2,3,45";
String[] result = input.split(",");

assertThat(result).contains("45","3","2", "1");
assertThat(result).containsExactly("1","2","3", "45");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드는 테스트 코드 시험 목적으로 작성하신건가요? 테스트 코드는 보통 src/test/java 패키지 내부에서 작성해요. 테스트 코드를 별도의 패키지에서 작성하는 이유가 뭘까요?

Comment on lines +29 to +31
for (String name : userInput.split(",")) {
carNames.add(name.trim());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream(), trim(), join() 등 자바에서 제공하는 api를 적극적으로 사용하진 부분이 좋습니다!

Comment on lines +32 to +34

//예외처리---------------------------------------------------
try {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석을 통해 코드에 대한 설명을 덧붙여 주셨네요. 코드를 읽는 입장에서 이해하기 편했어요. 다만, 주석을 사용하지 않고 코드 자체로 가독성을 챙길 수 있는 여러가지 방법이 있을 것 같아요. 함수를 이용하는 방법은 어떨까요?

Comment on lines +36 to +38
if (Name.length() > 5) {
throw new IllegalArgumentException();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalArgumentException 생성시 인자로 문자열을 넘겨줄 수 있어요. 예외의 원인을 담아서 예외 객체를 생성하면 어떤 장점이 있을까요?

Comment on lines +40 to +42
} catch (IllegalArgumentException e) {
return;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try-catch 문을 통해 예외 처리를 해주셨네요. catch 문 내부를 비워두셨는데, 이유가 있으신가요?

Comment on lines +58 to +59
//경주시작-------------------------------------------------
int ssc = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수의 역할이 잘 드러나도록 이름을 지어주시면 좋아요!

Comment on lines +67 to +69
int randomInt = Randoms.pickNumberInRange(0, 9);
if (randomInt > 3) {
score.set(ssc, score.get(ssc) + 1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요구사항에서 주어진 값을 상수로 처리하는건 어떻게 생각하시나요?

Comment on lines +75 to +82
int rank1 = 1;
int rank2 = 0;
for (int k = 0; score.size() - 1 > k; k++) {
rank2 = Math.max(score.get(k), score.get(k + 1));
if (rank2>rank1){
rank1=rank2;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가장 멀리 나간 자동차를 찾기 위한 로직 같아요. rank2 변수를 사용하지 않는 방법은 없을까요?

Comment on lines +84 to +86
if (carNames.size()==1){
rank1=score.get(0);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

바로 위 반복문의 종료 조건 score.size() - 1 때문에 추가한 코드 같아요. 위 기능에서 한번에 처리할 수 있을 것 같습니다.

@jaechu12 jaechu12 changed the title [김예슬_BackEnd] 1주차 과제 제출합니다. [김예슬_BackEnd] 2주차 과제 제출합니다. Mar 31, 2025
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.

2 participants