-
Notifications
You must be signed in to change notification settings - Fork 901
Expand file tree
/
Copy pathGameController.java
More file actions
37 lines (30 loc) · 1.19 KB
/
Copy pathGameController.java
File metadata and controls
37 lines (30 loc) · 1.19 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
package baseboll.myTrial.second.view;
import baseboll.myTrial.second.NumberProvider;
import baseboll.myTrial.second.checker.GameChecker;
import java.io.IOException;
public class GameController {
private final InputView inputView;
private final OutputView outputView;
private final GameChecker gameChecker;
private final NumberProvider numberProvider;
public GameController(InputView inputView, OutputView outputView, GameChecker gameChecker, NumberProvider numberProvider) {
this.inputView = inputView;
this.outputView = outputView;
this.gameChecker = gameChecker;
this.numberProvider = numberProvider;
}
private boolean correct(String input, String answer) {
return input.equals(answer);
}
public void game() throws IOException {
String answer = numberProvider.makeRandomAnswer();
System.out.println(answer);
String input = "";
while (!correct(input, answer)){
input = inputView.getInput(); // 인펏부터 받는다
String checked = gameChecker.check(input, answer);
outputView.sendOutput(checked);
}
if (inputView.wantContinue()) game();
}
}