-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathScore.java
More file actions
36 lines (29 loc) · 842 Bytes
/
Score.java
File metadata and controls
36 lines (29 loc) · 842 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
package baseball.model;
public class Score {
private final int strikes;
private final int balls;
private final int length;
private Score(int strikes, int balls, int length) {
this.strikes = strikes;
this.balls = balls;
this.length = length;
}
public static Score of(int strikes, int balls, int length) {
if (strikes < 0 || balls < 0) {
throw new IllegalArgumentException("스트라이크/볼은 음수일 수 없습니다.");
}
return new Score(strikes, balls, length);
}
public int getStrikes() {
return strikes;
}
public int getBalls() {
return balls;
}
public boolean isAllStrike() {
return strikes == length;
}
public boolean isNothing() {
return strikes == 0 && balls == 0;
}
}