-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathLottoRank.java
More file actions
39 lines (31 loc) · 1.05 KB
/
LottoRank.java
File metadata and controls
39 lines (31 loc) · 1.05 KB
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
package step2.domain;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
public enum LottoRank {
MATCH_3(3, 5_000, "3개 일치 (5000원)"),
MATCH_4(4, 50_000, "4개 일치 (50000원)"),
MATCH_5(5, 1_500_000, "5개 일치 (1500000원)"),
MATCH_6(6, 2_000_000_000, "6개 일치 (2000000000원)"),
NO_MATCH(0, 0, "NO_MATCH");
private static final Map<Integer, LottoRank> MATCH_MAP = Arrays.stream(values())
.collect(Collectors.toMap(rank -> rank.match, Function.identity()));
private final int match;
private final int money;
private final String description;
LottoRank(int match, int money, String description) {
this.match = match;
this.money = money;
this.description = description;
}
public static LottoRank fromMatch(int match) {
return MATCH_MAP.getOrDefault(match, NO_MATCH);
}
public int money() {
return money;
}
public String description() {
return description;
}
}