Skip to content
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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

yskim6772
Copy link
Member

No description provided.

Copy link

@JangIkhwan JangIkhwan left a 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);

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);

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));

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()) ? "*" : "")

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) {

Choose a reason for hiding this comment

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

Node에 Direction이 있고 어떤 값을 가지는지 알아야 해서 다른 객체와의 결합도가 늘어난 것 같아요. 캡슐화를 적용해볼까요?

Comment on lines +30 to +39
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++;
}
Copy link

@JangIkhwan JangIkhwan Sep 28, 2024

Choose a reason for hiding this comment

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

랜덤하게 그리는 로직이 깔끔하네요!

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.

3 participants