-
Notifications
You must be signed in to change notification settings - Fork 737
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
base: minji-go
Are you sure you want to change the base?
Step2 - 사다리(생성) #2315
Conversation
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 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("|"); | ||
} | ||
} |
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.
depth가 깊어보이는데 스트림과 메소드 추출을 활용하면 좋겠습니다!
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 "| "; | |
} |
메소드 이름은 예시이니 참고만 해주세요!
public List<List<Boolean>> getLadder() { | ||
return lines.getList(); | ||
} | ||
|
||
public List<String> getNames() { | ||
return names.getAll(); | ||
} |
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.
이 부분도
값을 풀어서 제공하고 있네요
혹시 외부에서 사용할 때 디미터 법칙을 지키기 위함일까요?
안녕하세요! 2단계 사다리 타기 미션도 잘부탁드려요 🥰