-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathGame.java
More file actions
33 lines (26 loc) · 774 Bytes
/
Game.java
File metadata and controls
33 lines (26 loc) · 774 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
package lotto.model;
import java.util.Set;
import lotto.util.DetailErrorMessage;
public class Game {
private Set<Integer> jackpotNumbers;
private Integer bonus;
Game(Set<Integer> jackpotNumbers) {
this.jackpotNumbers = jackpotNumbers;
}
//static factory pattern
public static Game setJackpot(Set<Integer> jackpotNumbers) {
return new Game(jackpotNumbers);
}
public void setBonus(int bonus) {
if (jackpotNumbers.contains(bonus)) {
throw new IllegalArgumentException(DetailErrorMessage.DUPLICATED.getMessage());
}
this.bonus = bonus;
}
public Set<Integer> getJackpotNumbers() {
return jackpotNumbers;
}
public Integer getBonus() {
return bonus;
}
}