forked from woowacourse-precourse/java-baseball-6
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApplication.java
More file actions
40 lines (33 loc) · 1.41 KB
/
Application.java
File metadata and controls
40 lines (33 loc) · 1.41 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
37
38
39
40
package baseball;
import camp.nextstep.edu.missionutils.Console;
import java.util.List;
import static baseball.utils.DataUtils.convertToIntList;
import static baseball.utils.DataUtils.generateRandomNumbers;
import static baseball.utils.IOUtils.getResult;
import static baseball.utils.IOUtils.validateInput;
public class Application {
public static void main(String[] args) {
boolean playAgain = true;
while (playAgain) {
List<Integer> computerNumbers = generateRandomNumbers();
boolean gameOver = false;
System.out.println("숫자 야구 게임을 시작합니다.");
while (!gameOver) {
System.out.print("숫자를 입력해주세요 : ");
String userInput = Console.readLine();
validateInput(userInput);
List<Integer> userNumbers = convertToIntList(userInput);
Boolean is3Strike = getResult(computerNumbers, userNumbers);
if (is3Strike) {
gameOver = true;
System.out.println("3개의 숫자를 모두 맞히셨습니다! 게임 종료");
}
}
System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요.");
String choice = Console.readLine();
if (choice.equals("2")) {
playAgain = false;
}
}
}
}