-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathView.java
More file actions
36 lines (32 loc) · 1.34 KB
/
View.java
File metadata and controls
36 lines (32 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class View {
private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
public Integer[] getPlayerInput() throws IOException {
System.out.println("숫자를 입력해주세요 : ");
String input = reader.readLine();
String[] numbersInString = input.split("");
Integer[] numbers = new Integer[3];
for (int i = 0; i < 3; i++) {
numbers[i] = Integer.parseInt(numbersInString[i]);
}
return numbers;
}
public void printScore(int[] scores) {
String strike = "";
String ball = "";
if (scores[0] != 0) strike = scores[0] + "스트라이크 ";
if (scores[1] != 0) ball = scores[1] + "볼 ";
if (scores[0]+scores[1] != 0) System.out.println(strike + ball);
if (scores[0]+scores[1] == 0) System.out.println("낫싱");
}
public boolean getPlayerRetryChoice() throws IOException{
System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요.");
String playerChoice = reader.readLine();
if (playerChoice.equals("1")) return true;
if (playerChoice.equals("2")) return false;
return getPlayerRetryChoice();
}
}