-
Notifications
You must be signed in to change notification settings - Fork 423
Expand file tree
/
Copy pathHit.java
More file actions
43 lines (34 loc) · 865 Bytes
/
Hit.java
File metadata and controls
43 lines (34 loc) · 865 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
package bowling.domain;
public class Hit {
public static final int MIN = 0;
public static final int MAX = 10;
private final int hit;
public Hit(int hit) {
validate(hit);
this.hit = hit;
}
private void validate(int hit) {
if (hit < MIN || hit > MAX) {
throw new IllegalArgumentException("범위를 벗어나는 점수가 입력되었습니다.");
}
}
public Hit plus(Hit target) {
return new Hit(hit + target.hit);
}
public boolean isMin() {
return hit == MIN;
}
public boolean isMax() {
return hit == MAX;
}
public int getScore() {
return hit;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Hit)) {
return false;
}
return hit == ((Hit) obj).hit;
}
}