-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathStrikeBallCount.java
More file actions
38 lines (30 loc) · 897 Bytes
/
StrikeBallCount.java
File metadata and controls
38 lines (30 loc) · 897 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
package service;
public class StrikeBallCount {
private int strikeCount = 0;
private int ballCount = 0;
public int getStrikeCount() {
return strikeCount;
}
public int getBallCount() {
return ballCount;
}
public void updateStrike() {
this.strikeCount += 1;
}
public void updateBall() {
this.ballCount += 1;
}
public Boolean isCorrect() {
return this.strikeCount == 3;
}
public Boolean isNothing() {
return this.ballCount == 0 & this.strikeCount == 0;
}
public String getResultString() {
StringBuilder res = new StringBuilder();
if (this.strikeCount > 0) res.append(strikeCount).append("스트라이크 ");
if (this.ballCount > 0) res.append(ballCount).append("볼");
if (this.isNothing()) res.append("낫싱");
return res.toString();
}
}