forked from woowacourse-precourse/java-baseball-6
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathGame.java
More file actions
42 lines (38 loc) · 1.18 KB
/
Game.java
File metadata and controls
42 lines (38 loc) · 1.18 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
41
42
package baseball;
public class Game {
private Computer computer;
private Input input;
private Go go;
public Game(){
this.computer = new Computer();
this.input = new Input();
this.go = new Go();
}
public void newGame(){
while(true){
System.out.println("숫자를 입력해주세요 : ");
int[] player = input.getInput();
String result = go.Check(computer.getCom(), player);
System.out.println(result);
if(result.equals("3스트라이크")){
break;
}
}
}
public void start(){
while(true){
System.out.println("숫자 야구 게임을 시작합니다.");
computer.Random();
newGame();
System.out.println("3개의 숫자를 모두 맞히셨습니다! 게임 종료");
System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요.");
String next = input.getUserInput();
if (next.equals("2")) {
break;
}
else if(!next.equals("1")){
continue;
}
}
}
}