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

Step2 - 사다리(생성) #2315

Open
wants to merge 15 commits into
base: minji-go
Choose a base branch
from
Open

Step2 - 사다리(생성) #2315

wants to merge 15 commits into from

Conversation

minji-go
Copy link

@minji-go minji-go commented Apr 4, 2025

안녕하세요! 2단계 사다리 타기 미션도 잘부탁드려요 🥰

Copy link
Member

@nooose nooose 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 16 to 28
public void printLadders(List<List<Boolean>> ladders) {
for(List<Boolean> ladder : ladders) {
System.out.print(" ");
for(Boolean connected : ladder) {
if(connected) {
System.out.print("|-----");
} else {
System.out.print("| ");
}
}
System.out.println("|");
}
}
Copy link
Member

Choose a reason for hiding this comment

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

depth가 깊어보이는데 스트림과 메소드 추출을 활용하면 좋겠습니다!

Suggested change
public void printLadders(List<List<Boolean>> ladders) {
for(List<Boolean> ladder : ladders) {
System.out.print(" ");
for(Boolean connected : ladder) {
if(connected) {
System.out.print("|-----");
} else {
System.out.print("| ");
}
}
System.out.println("|");
}
}
public void printLadders(List<List<Boolean>> ladders) {
for (List<Boolean> ladder : ladders) {
var lines = ladder.stream()
.map(this::make)
.collect(Collectors.joining("", " ", "|"));
System.out.println(lines);
}
}
private String make(boolean connected) {
if (connected) {
return "|-----";
}
return "| ";
}

메소드 이름은 예시이니 참고만 해주세요!

Comment on lines +19 to +25
public List<List<Boolean>> getLadder() {
return lines.getList();
}

public List<String> getNames() {
return names.getAll();
}
Copy link
Member

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.

2 participants