-
Notifications
You must be signed in to change notification settings - Fork 26
2주차 미션 / 서버 3조 김나은 #39
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: main
Are you sure you want to change the base?
Conversation
…word in Row class
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.
고생 많으셨습니다~ 👍
| } | ||
|
|
||
| // 사다리 상태를 출력하는 메서드 | ||
| private void printLadder(Position position, int currentRow) { |
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.
인자 row도 Position 객체이면 좋을 것 같네요
| public class LadderSize { | ||
| private final GreaterThanOne numberOfRow; | ||
| private final GreaterThanOne numberOfPerson; | ||
| private static final double LINE_PROBABILITY = 0.3; |
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.
오 가로선 비율을 상수로 설정한 점 좋은 것 같아요! 나중에 봐도 이 값의 의미를 바로 알겠네요
| public void printUserRow(Position position) { | ||
| StringBuilder sb = new StringBuilder(); | ||
| for (int i = 0; i < nodes.length; i++) { | ||
| if (i == position.getPosition()) { |
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.
getter를 쓰니 캡슐화가 깨지는 것 같아요. position 객체의 메소드 내부에서 값을 비교해보는 건 어떨까요?
|
|
||
| while (positions.size() < linesToCreate) { | ||
| int row = random.nextInt(numberOfRow.getNumber()); | ||
| int col = random.nextInt(numberOfPerson.getNumber() - 1); // 선이 열 사이에 있으므로 열 크기보다 1 작게 선택 |
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.
아래에 있는 검증 메소드로 해결할 수 있겠지만, 미리 값의 범위를 제한한 부분에서 꼼꼼함이 보이네요!
| LadderPosition newPosition = new LadderPosition(row, col); | ||
|
|
||
| // 해당 위치에 선을 그릴 수 있는지 확인 | ||
| if (positions.contains(newPosition) || !canDrawLine(Position.from(row), Position.from(col))) { |
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.
중복 확인이 잘 되는지 확인해보셨나요? 제가 검색해본 바로는 HashSet의 contains()는 두 객체의 주소가 같은지 검증한다고 하거든요... 중복확인이 잘 동작할지 확신이 안 드네요.
| } | ||
|
|
||
| @Override | ||
| public void drawLine(Position row, Position col) { |
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.
오버라이딩한 메소드가 모두 동일한 일을 하도록 구현해서 좋네요
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| public class RandomLadderGameTest { |
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.
팩토리가 만든 객체도 테스트해보는 건 어떨까요?
이번 주차도 부족함이 많은 코드입니다 🥲
저번 주차 코드 리뷰가 도움이 많이 되었습니다.
이번 주차도 잘부탁드립니다! 감사합니다 😊