-
Notifications
You must be signed in to change notification settings - Fork 351
Expand file tree
/
Copy pathCoin.java
More file actions
42 lines (36 loc) · 1.05 KB
/
Copy pathCoin.java
File metadata and controls
42 lines (36 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
40
41
42
package vendingmachine.enums;
import camp.nextstep.edu.missionutils.Randoms;
import vendingmachine.view.InputView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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 static int getRandomCoin(){
List<Integer> coins = new ArrayList<>();
coins.add(COIN_10.amount);
coins.add(COIN_50.amount);
coins.add(COIN_100.amount);
coins.add(COIN_500.amount);
return Randoms.pickNumberInList(coins);
}
public static int getIndex(int coin){
if(COIN_10.amount == coin)return 3;
if(COIN_50.amount == coin)return 2;
if(COIN_100.amount == coin)return 1;
return 0;
}
// 추가 기능 구현
public static boolean isDivideMinCoin(String input) {
if (Integer.parseInt(input) % COIN_10.amount == 0) return true;
return false;
}
}