-
Notifications
You must be signed in to change notification settings - Fork 901
Expand file tree
/
Copy pathPlayResult.java
More file actions
48 lines (35 loc) · 887 Bytes
/
Copy pathPlayResult.java
File metadata and controls
48 lines (35 loc) · 887 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package baseball;
public class PlayResult {
private int strike = 0;
private int ball = 0;
public int getStrike() {
return this.strike;
}
public int getBall() {
return this.ball;
}
public void report(BallStatus status) {
if (status.equals(BallStatus.STRIKE)) {
this.strike += 1;
}
if (status.equals(BallStatus.BALL)) {
this.ball += 1;
}
}
public boolean isGameEnd() {
return this.strike == 3;
}
@Override
public String toString() {
if (this.ball > 0 && this.strike > 0) {
return ball + "볼 " + strike + "스트라이크";
}
if (this.ball > 0) {
return ball + "볼";
}
if (this.strike > 0) {
return strike + "스트라이크";
}
return "낫싱";
}
}