forked from woowacourse-precourse/java-lotto-6
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathErrorChecker.java
More file actions
64 lines (62 loc) · 1.45 KB
/
ErrorChecker.java
File metadata and controls
64 lines (62 loc) · 1.45 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package lotto;
import java.util.HashSet;
import java.util.List;
public class ErrorChecker {
public ErrorChecker(){
}
public boolean checkString(String str){
if(!str.matches("-?\\d+")){
return true;
}
return false;
}
public boolean checkNegativeNumber(int val){
if(val<=0){
return true;
}
return false;
}
public boolean checkDivision(int price){
if(price%1000!=0){
return true;
}
return false;
}
public boolean checkAmount(String[] str){
if(str.length!=6) {
return true;
}
return false;
}
public boolean checkRange(int val){
if(val<1 || val>45) {
return true;
}
return false;
}
public boolean checkDuplication(List<Integer> val){
HashSet<Integer> uniqueVal = new HashSet<>();
for(int v : val) {
if (!uniqueVal.add(v)) {
return true;
}
}
return false;
}
public boolean checkInputFormat(String[] str){
for(String s : str) {
if (!s.matches("-?\\d+")) {
return true;
}
}
return false;
}
public boolean checkBonusDuplication(List<Integer> numbers, int bonus){
for(int num : numbers){
if(num == bonus) {
return true;
}
}
return false;
}
}