Skip to content

[3단계 - 사다리] 이지현 미션 제출합니다 #67

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

Merged
merged 7 commits into from
Jun 9, 2025

Conversation

izzy80
Copy link

@izzy80 izzy80 commented Jun 7, 2025

안녕하세요 주노!
이번 리뷰도 잘 부탁드립니다 😊

고민했던 부분

  • Width/Height를 도메인 용어(Column/Row)로 통일했습니다.
  • 2단계 리턴 로직에서 “한 줄이 빈” 현상을 발견하고 수정했습니다.
    • 제가 생각하기로는 기존 로직이 수정하려는 열보다 앞 선열에서도 사다리가 1개뿐이라, 새로운 사다리를 추가하려고 할 때, 양쪽 사다리를 강제로 없애는데, 이때 모두 제거하는 것 같아서, 더 안정적인 위치에 사다리를 추가하고, 오른쪽 불필요한 사다리를 제거하는 방식으로 개선했습니다.

궁금한 점

추가로 테스트하는 부분 고정된 사다리로 할려고 하는데 꼬였는지 "디버그용 바이트코드(또는 컴파일된 클래스)와 에디터에 열려 있는 소스 파일의 라인 번호가 맞지 않는다"라는 경고가 나오네요. (이 부분은 따로 수정해서 올리도록 하겠습니다 ㅠ )
rebuild랑 cache도 지워봤는데 해결이 안 되어서 밀어버렸는데 혹시 왜 이런 문제가 발생하는지 아실까요?

Copy link

@dd-jiyun dd-jiyun left a comment

Choose a reason for hiding this comment

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

지현님! 코드 3단계 고생하셨어요 🔥

저번에 Column하고 Row 말씀하셨었는데 수정하셨네요!

간단한 코멘트 남겼어요. 다음 미션도 화이팅입니다 !!


public Column {
if (value < MIN_COLUMN) {
throw new IllegalArgumentException("사다리의 넓이는 " + MIN_COLUMN + " 이상이어야 합니다.");
Copy link

Choose a reason for hiding this comment

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

자바 15부터 지원되는 .formatted() 메서드도 고려해보시면 좋을 것 같아요 👍🏻

Copy link
Author

Choose a reason for hiding this comment

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

오 한 번 이용해보도록 하겠습니다. 좋은 방법 알려주셔서 감사합니다 😊

private static final int MIN_ROW = 1;

public Row {
if (value < MIN_ROW ) {
Copy link

Choose a reason for hiding this comment

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

intelliJ에서 지원하는 단축키로 포맷팅하면 코드 컨벤션에 맞게 정렬하기 수월해요!

Choose a reason for hiding this comment

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

Window : Crtl + Alt + L


import java.util.Map;

public record LadderResult(Map<Integer, Integer> result) {}
Copy link

Choose a reason for hiding this comment

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

오 result를 Map을 사용하셨네요 👍🏻

Copy link
Author

Choose a reason for hiding this comment

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

네! 시작점과 끝점을 같이 저장하기 위해 Map을 사용해봤습니다 🙂
이렇게 하니까 결과를 한 번에 관리하기 편해서 좋더라고요!

sb.append(start)
.append(" -> ")
.append(end)
.append(System.lineSeparator())
Copy link

Choose a reason for hiding this comment

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

System.lineSeparator() 사용 👍🏻

@jisoo78
Copy link

jisoo78 commented Jun 9, 2025

지현님 안녕하세요 이번 3단계 미션 고생 많았습니다
항상 깔끔하게 작성한 코드 보고 많이 배우고 있습니다
이번 주도 화이팅!


OutputView.printLadder(game.getLadder());

//사다리 게임 결과 출력
Map<Integer, Integer> resultMap = new HashMap<>();
Copy link

Choose a reason for hiding this comment

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

시작점과 도착점을 확인하기 위해 HashMap을 사용하신 건가요??

Copy link
Author

Choose a reason for hiding this comment

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

넵 맞습니다! 결과를 한 번에 관리하기 위해서 HashMap을 사용했습니다!

Copy link

@Choi-JJunho Choi-JJunho left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!
Width, Height, Col, Row 혼재된 개념을 잘 통일해주셨군요! 👏
몇가지 코멘트 확인 부탁드립니다~

Comment on lines +17 to +41
public int play(int start) {
int position = start;
for (int row = 0; row < ladder.getLines().size(); row++) {
position = movePosition(position, ladder.getLines().get(row));
}
return position;
}

private int movePosition(int position, Line line) {
if (canMoveLeft(position, line)) {
return position - 1;
}
if (canMoveRight(position, line)) {
return position + 1;
}
return position;
}

private boolean canMoveLeft(int position, Line line) {
return position > 0 && line.isLinkedAt(position - 1);
}

private boolean canMoveRight(int position, Line line) {
return position < line.getLinks().size() && line.isLinkedAt(position);
}

Choose a reason for hiding this comment

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

다음 요구사항을 만족시켜볼까요?

Java Enum을 적용한다.

private static final int MIN_ROW = 1;

public Row {
if (value < MIN_ROW ) {

Choose a reason for hiding this comment

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

Window : Crtl + Alt + L


public static void printResult(LadderResult result) {
StringBuilder sb = new StringBuilder();
sb.append("\n");

Choose a reason for hiding this comment

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

여기에서는 System.lineSeparator() 를 사용하지 않은 이유가 있을까요?


OutputView.printLadder(game.getLadder());

//사다리 게임 결과 출력
Map<Integer, Integer> resultMap = new HashMap<>();

Choose a reason for hiding this comment

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

제 생각에는 Map<Int,Int>는 의미있는 값을 가지고 있긴 어렵다고 생각이 드네요 🤔
물론 변수명으로 표현할 수는 있겠지만 key, value 각각에 의미를 부여하기에는 어려워보이기도 해요
map.get(something) 을 해서 나온 결과값은 어떤 의미를 부여해야할지 계속 고민을 해야할 것 같기도 해요

이럴거면 의미를 명확히 가지고있는 LadderResult에게 주체를 갖게하는건 어떨까요?

한줄요약: Map을 생성하는것이 아닌 LadderResult를 생성하여 값을 추가해주는건 어떻게생각하시나요?

@boorownie boorownie merged commit 78f8e9c into next-step:izzy80 Jun 9, 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.

5 participants