Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/main/java/view/InputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package view;

import java.util.*;

public class InputView {
private static final Scanner scanner = new Scanner(System.in);

public static List<String> getPlayerNames() {
System.out.println("참여할 사람 이름을 입력하세요. (이름은 쉼표(,)로 구분하세요)");
return Arrays.asList(scanner.nextLine().split(","));
}

public static List<String> getResults() {
System.out.println("실행 결과를 입력하세요. (결과는 쉼표(,)로 구분하세요)");
return Arrays.asList(scanner.nextLine().split(","));
}

public static int getLadderHeight() {
System.out.println("최대 사다리 높이는 몇 개인가요?");
return scanner.nextInt();
}

public static String getQuery() {
System.out.println("결과를 보고 싶은 사람은?");
return scanner.next();
Copy link

Choose a reason for hiding this comment

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

오....!!! nextInt()를 하면 개행 문자가 버퍼에 남아있는 문제가 있어서 다음에 nextLine() 호출 시 바로 개행 문자가 입력되는 문제가 있었는데 next()를 쓰면 개행 문자를 포함하지 않는군요.

좋은 정보 하나 알아갑니다!! 👍

Copy link
Author

Choose a reason for hiding this comment

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

넵 맞습니다 ㅎㅎ 김상진 교수님의 자바프로그래밍에서 배웠습니다! 도움이 되었다니 기쁩니다!

}
}