-
Notifications
You must be signed in to change notification settings - Fork 351
Expand file tree
/
Copy pathCoin.java
More file actions
41 lines (32 loc) · 826 Bytes
/
Copy pathCoin.java
File metadata and controls
41 lines (32 loc) · 826 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
package vendingmachine;
import camp.nextstep.edu.missionutils.Randoms;
import java.util.List;
import java.util.Arrays;
import java.util.stream.Collectors;
public enum Coin {
COIN_500(500),
COIN_100(100),
COIN_50(50),
COIN_10(10);
private final int amount;
Coin(final int amount) {
this.amount = amount;
}
// 추가 기능 구현
public int getAmount(){
return this.amount;
}
public static Coin of(int amount){
for(Coin tempCoin : values()){
if(tempCoin.amount == amount){
return tempCoin;
}
}
return null;
}
public static List<Integer> getCoins(){
return Arrays.stream(Coin.values())
.map(Coin::getAmount)
.collect(Collectors.toList());
}
}