Skip to content

[4,5단계 - 게임 실행, 리팩터링] 최지수 미션 제출합니다 #71

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

Merged
merged 2 commits into from
Jun 15, 2025

Conversation

jisoo78
Copy link

@jisoo78 jisoo78 commented Jun 11, 2025

주노 안녕하세요
벌써 사다리미션이 끝나가네요 다음 미션도 화이팅입니다

고민한 점

사용자 입력에서 어떻게 하면 깔끔하게 받을 수 있을까 생각해 봤어요
글자 수(이름)를 제한을 두기도 하면서 생각을 했는데 결과값을 일정한 간격으로 줄바꿈 없이 나열하는 게 가장 깔끔하게 나오더라고요 이 부분에서 많이 고민해 봤습니다

간단 후기

지금은 실행 결과가 잘 나오지만 나중에 이름에 글자 수 제한을 두는 것도 생각해 봐야겠어요

Copy link

@dd-jiyun dd-jiyun left a comment

Choose a reason for hiding this comment

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

4,5단계 고생 많으셨어요!

간단한 코멘트 남겨두었으니 답변 부탁드립니다 😆

}
System.out.println();

while (true) {

Choose a reason for hiding this comment

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

while로 재입력을 받으면 indent 요구사항을 준수하지 못하게 되는 거 같아요!
저도 같은 고민을 했었는데 어떻게 하면 개선할 수 있을지 고민해보시면 좋을 것 같습니다 👍🏻

positions[i] = i;
}

// depth가 2를 넘어가네... 수정

Choose a reason for hiding this comment

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

😂

Choose a reason for hiding this comment

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

수정..해주실거죠? ㅎㅎ

System.out.println("사다리의 높이(|의 새로 개수)는 몇 개인가요");
int height = scanner.nextInt();
System.out.println("실행결과");
System.out.println("참여할 사람 이름을 입력하세요. (이름은 쉼표(,)로 구분하세요)");

Choose a reason for hiding this comment

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

OutputView처럼 InputView 나눠보시면 좋을 것 같아요!

Copy link
Author

Choose a reason for hiding this comment

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

오 좋은 생각입니다 함 진행해볼게요!

if (width < WIDTH_LINE || height < HEIGHT_LINE) {
System.out.println("넓이는 최소 2, 높이는 최소 1 이상 입력해주세요");
System.out.println("실행 결과를 입력하세요. (결과는 쉼표(,)로 구분하세요)");
List<String> results = Arrays.stream(scanner.nextLine().split(","))

Choose a reason for hiding this comment

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

쉼표와 같이 자주 사용되는 경우 상수화를 할 수 있겠네요!

Copy link
Author

Choose a reason for hiding this comment

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

이런 경우도 상수화가 가능하겠네요 감사합니다!

Copy link

@dd-jiyun dd-jiyun left a comment

Choose a reason for hiding this comment

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

나중에 이름에 글자 수 제한을 두는 것도 생각해 봐야겠어요

저희 요구사항에 이름 5자 제한있어요 🙌 반영해주시면 될 것 같습니당!

추가로 실행해보면서 발생할 수 있는 예외들을 떠올려봤어요!

  • 이름과 결과를 입력하지 않았을 경우 (빈 값 또는 null)
  • 사람 수와 결과 수가 일치하지 않을 경우
  • 최대 사다리 높이를 숫자가 아닌 값을 입력했을 경우
  • 중복된 이름이 존재할 경우

아래처럼 IntelliJ에서 노란 밑줄이 생기는 부분은 경고(WARNING) 라는 의미예요.
성능, null 가능성, 사용하지 않는 변수 등 IDE가 잠재적 문제를 사전에 알려주는 힌트이니 한 번씩 체크해보면 실수를 줄이는 데 도움이 많이 되더라구요!

image

int[] resultLadder = ladderResult.resultIndex(ladder);
System.out.println("실행 결과");
System.out.println(results.get(resultLadder[idx]));
break;

Choose a reason for hiding this comment

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

결과를 보고 싶은 사람을 한 명 지정하면 그대로 게임이 끝나네요!
그러면 전체 결과는 알 수 없는 거 같아요.
의도하신 걸까요??

Copy link
Author

@jisoo78 jisoo78 Jun 13, 2025

Choose a reason for hiding this comment

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

아하 이 부분은 제가 잘 못 이해하고 넘어간 거 같아요
결과를 보고 싶은 사람은?
neo
실행 결과

결과를 보고 싶은 사람은?
all
실행 결과
예시에 이런식으로 나와있는데
결과를 보고 싶은 사람과 전체 결과를 따로 생각하고 진행했었네요
다시 수정해 볼게요!

Comment on lines 24 to 28
List<String> names = new ArrayList<>();
for (String name : ArrayNames) {
name = name.trim();
names.add(name);
}

Choose a reason for hiding this comment

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

아래 코드에서 resultsstream을 사용해 처리해주셨는데 namesfor문으로 구현하셨네요.
혹시 두 방식을 나눠서 사용하신 특별한 이유가 있을까요?

직접 사용해보면서 어떤 방식이 더 편하셨는지도 궁금합니다!
개인적으로는 동일한 처리 로직이 반복될 때는 하나의 방식으로 통일해주는 것도 유지보수 관점에서 도움이 된다고 생각해요 😊

Copy link
Author

Choose a reason for hiding this comment

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

개인적으로 아직 stream 을 활용하는 게 익숙하지가 않아서 무의식적으로 반복문이 자주 나오고 있어요
요구사항에 맞춰서 진행하려면 stream 을 사용하면서 통일하는 게 좋아 보이네요

@izzy80
Copy link

izzy80 commented Jun 13, 2025

4,5단계까지 오느라 정말 고생 많았어요! 끝까지 화이팅입니다! 😊

.anyMatch(j -> prevLine.get(j) && nextLine.get(j));
List<Boolean> nextLine;
boolean collision;
do {
Copy link

Choose a reason for hiding this comment

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

이 부분도 2-depth가 넘어가는데 method로 빼는 것이 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

좋은 생각입니다!

LadderResult ladderResult = new LadderResult();
List<List<Boolean>> lines = ladder.getLines();
for (String name : names) {
System.out.print(String.format("%-5s", name));
Copy link

Choose a reason for hiding this comment

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

"%-5s"에 들어가는 5 부분을 상수화로 빼도 괜찮을 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

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

아하 이 부분도 상수화해볼게요


while (true) {
System.out.println("결과를 보고 싶은 사람은?");
String result = scanner.next().trim();
Copy link

Choose a reason for hiding this comment

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

java 11부터 strip() 이 생겼는데 이 함수를 사용해보는 것이 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

오 좋은 정보 감사해요 사용해볼게요!

Copy link

@Choi-JJunho Choi-JJunho 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 +30 to +31
System.out.println("실행 결과를 입력하세요. (결과는 쉼표(,)로 구분하세요)");
List<String> results = Arrays.stream(scanner.nextLine().split(","))

Choose a reason for hiding this comment

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

image

실행 결과가 비어있는 경우도 있네요 🤔
참여자수와 실행결과의 수는 같아야할거같은데 어떻게 생각하시나요?

Copy link
Author

Choose a reason for hiding this comment

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

아하... 참여자 수와 실행 결과의 수가 항상 같다고 생각하고 넘어갔네요

while (true) {
System.out.println("결과를 보고 싶은 사람은?");
String result = scanner.next().trim();
boolean isAll = "all".equalsIgnoreCase(result);

Choose a reason for hiding this comment

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

ignoreCase를 사용해주셨군요 👍

Comment on lines +13 to +32
@Test
@DisplayName("입력한 이름이 일치하는 지 확인")
void inputNameTest() {
String input = " jisoo1 ,jisoo2, jisoo3, jisoo4, jisoo5";
String[] ArrayNames = input.split(",");
List<String> names = new ArrayList<>();
for (String name : ArrayNames) {
name = name.trim();
names.add(name);
}

List<String> expected = List.of(
"jisoo1",
"jisoo2",
"jisoo3",
"jisoo4",
"jisoo5"
);
assertEquals(expected, names);
}

Choose a reason for hiding this comment

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

이 테스트는 어떤 목적을 가지고있을까요?

Copy link
Author

Choose a reason for hiding this comment

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

참여한 사람의 이름과 실행 결과에서 보고 싶은 사람이 일치하는지 확인하는 목적입니다

positions[i] = i;
}

// depth가 2를 넘어가네... 수정

Choose a reason for hiding this comment

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

수정..해주실거죠? ㅎㅎ

Copy link

@Choi-JJunho Choi-JJunho left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍

@boorownie boorownie merged commit 4e004a6 into next-step:jisoo78 Jun 15, 2025
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.

5 participants