-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathOutput.java
More file actions
34 lines (29 loc) · 1.19 KB
/
Output.java
File metadata and controls
34 lines (29 loc) · 1.19 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
package lotto;
import java.util.Map;
public class Output {
public static void printLottoAmount(int lottoAmount){
System.out.println(lottoAmount +"개를 구매했습니다.");
}
public static void printLottos(Lottos lottos){
lottos.getLottos().stream()
.forEach(lotto -> System.out.println(lotto.getNumbers().toString()));
}
public static void printResults (Map<WinningRank, Integer> winningInfo){
for(Map.Entry<WinningRank,Integer> entry : winningInfo.entrySet()){
WinningRank winningRank = entry.getKey();
int value = entry.getValue();
System.out.println( winningRank.ordinal()+1 + "개 일치 (" + winningRank.getWinningPrice() +"원) - " + value + "개");
}
}
public static double calcEarning(Map<WinningRank, Integer> winningInfo, int money){
int sum = 0;
for(Map.Entry<WinningRank,Integer> entry : winningInfo.entrySet()){
WinningRank winningRank = entry.getKey();
int value = entry.getValue();
if(value >= 1){
sum += value * winningRank.getWinningPrice();
}
}
return Math.round(sum/money);
}
}