-
Notifications
You must be signed in to change notification settings - Fork 26
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
2주차 미션 / 서버 3조 김윤서 #46
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.
코드가 전반적으로 깔끔해요. 고생 많으셨습니다~~
public class LadderGameFactory { | ||
|
||
public static LadderGame createRandomLadderGame(GreaterThanOne numberOfRow, GreaterThanOne numberOfPerson) { | ||
LadderCreatorInterface ladderCreator = new LadderAutoCreator(numberOfRow, numberOfPerson); |
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.
팩토리 잘 만드신 것 같아요. game 객체를 만드는 코드를 한 곳에서 관리할 수 있으니 수정이 편해지겠네요!
rows[i] = new Row(numberOfPerson); | ||
} | ||
|
||
createRandomLines(numberOfPerson); |
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.
객체 생성 시에 랜덤 사다리를 그리는 것 괜찮네요!
StringBuilder ladderBuilder = new StringBuilder(); | ||
|
||
for (int i = 0; i < rows.length; i++) { | ||
ladderBuilder.append(rows[i].printRow(position, i == 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.
음 제어 변수로 별을 찍을지 결정하는 것 괜찮은 것 같은데, 이런 제어 결합도는 혼란을 일으킬 수 있으니 주의해서 사용해야할 것 같습니다.
|
||
for (int i = 0; i < nodes.length; i++) { | ||
rowBuilder.append(getNodeIndex(i)) | ||
.append((isCurrentRow && 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.
position 객체의 내부 값이 getter로 노출되네요. 메소드 내부에서 값 비교를 하면 캡슐화를 이룰 수 있지 않을까요?
return IsLineAtPosition; | ||
} | ||
|
||
private String getNodeIndex(int index) { |
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.
Node에 Direction이 있고 어떤 값을 가지는지 알아야 해서 다른 객체와의 결합도가 늘어난 것 같아요. 캡슐화를 적용해볼까요?
while (linesDrawn < numberOfLines) { | ||
int randomRow = random.nextInt(rows.length); | ||
int randomCol = random.nextInt(numberOfPerson.getNumber() - 1); | ||
|
||
Position position = Position.from(randomCol); | ||
|
||
if (rows[randomRow].canDrawLineAt(position.getPosition())) { | ||
rows[randomRow].drawLine(position); | ||
linesDrawn++; | ||
} |
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.
랜덤하게 그리는 로직이 깔끔하네요!
No description provided.