-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathStatistics.java
More file actions
35 lines (27 loc) · 1021 Bytes
/
Statistics.java
File metadata and controls
35 lines (27 loc) · 1021 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
package lotto.domain;
import lotto.domain.dto.WinningResult;
import lotto.domain.result.GameResult;
import lotto.domain.result.GameResults;
import java.util.List;
import java.util.stream.Collectors;
public class Statistics {
private static final int IS_EQUAL_RATE = 1;
private final GameResults gameResults;
private final int purchaseAmount;
public Statistics(GameResults gameResults, int purchaseAmount) {
this.gameResults = gameResults;
this.purchaseAmount = purchaseAmount;
}
public List<WinningResult> winningResults() {
return GameResult.valuesWithoutUnderThreeMatched()
.stream()
.map(gameResult -> new WinningResult(gameResults.count(gameResult), gameResult))
.collect(Collectors.toList());
}
public double calculateEarningRate() {
return gameResults.calculatePrize() / purchaseAmount;
}
public boolean isProfit(double earningRate) {
return earningRate > IS_EQUAL_RATE;
}
}