-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathEngine.java
More file actions
31 lines (28 loc) · 801 Bytes
/
Engine.java
File metadata and controls
31 lines (28 loc) · 801 Bytes
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
package baseball;
public class Engine {
public void playBall() {
int flag = 1;
while (flag == 1) {
flag = match();
}
}
private int match() {
Console console = new Console();
Pitcher pitcher = new Pitcher();
String target = pitcher.generateNumber();
batting(console, target);
return console.endGame();
}
private void batting(Console console, String target) {
int strike = 0;
int ball;
Referee referee = new Referee();
while (strike != 3) {
String input = console.getInput();
int[] result = referee.judge(target, input);
strike = result[0];
ball = result[1];
console.printResult(strike, ball);
}
}
}