-
Notifications
You must be signed in to change notification settings - Fork 732
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단계 - 사다리 (생성) #2319
base: melodist
Are you sure you want to change the base?
2단계 - 사다리 (생성) #2319
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.
이번 단계도 고생하셨습니다!
구조적인 질문을 드렸으니 한번 확인부탁드립니다~
언제든 궁금한게 있다면 슬랙 DM주새요!
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
public class LadderLineGenerator { |
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 Ladder { | ||
private final List<LadderLine> ladderLines; | ||
|
||
public Ladder(int height, int width) { |
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.
지금 여기서 잘 만들어주셨는데,
사다리를 고민해보면
사다리 갯수가 있을꺼고. (이게 높이의 갯수로 보입니다.)
그리고 width인 넓이들이 존쟇라거 같아요.
이걸 한번 나타내봐도 좋을거 같습니다.
실제 사다리 하나가 어떠한 결과를 반환해야 하지 않을까 생각이 듭니다.
이번 단계에서는 기존에 적용하던 원칙을 지키는 것과 더불어 Stream 적용에 집중했습니다.
List 를 그대로 반환하는 대신, 리스트의 크기를 반환하는 메소드와 리스트의 인덱스에 해당하는 원소에 접근하는 메소드를 구현하여 IntStream 을 적용했는데요.
리스트를 그대로 반환하는 것에 비해 객체 내부의 필드에 직접 접근하는 것을 막을 수 있었지만 코드의 양 자체는 늘었고 이것이 정말 효율적인지는 좀 더 생각해볼 여지가 있을 거 같습니다.
감사합니다.