forked from woowacourse/java-baseball-precourse
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathExceptionContoller.java
More file actions
38 lines (33 loc) · 1.14 KB
/
ExceptionContoller.java
File metadata and controls
38 lines (33 loc) · 1.14 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
package baseball;
import java.util.HashSet;
import java.util.Set;
public class ExceptionContoller {
public void notIntegerException(String Number){
for(int i=0; i<NumberInfo.SIZE_OF_NUMBER.getNumberInfo(); i++){
if(!Character.isDigit(Number.charAt(i))){
throw new IllegalArgumentException();
}
}
}
public void reduplicationException(String Number){
Set<Character> set = new HashSet<>();
for(int i=0; i<NumberInfo.SIZE_OF_NUMBER.getNumberInfo(); i++){
set.add(Number.charAt(i));
}
if(!(set.size() == NumberInfo.SIZE_OF_NUMBER.getNumberInfo())){
throw new IllegalArgumentException();
}
}
public void notThreeDigitException(String Number){
if(Number.length() != NumberInfo.SIZE_OF_NUMBER.getNumberInfo()){
throw new IllegalArgumentException();
}
}
public void zeroValueException(String Number){
for(int i=0; i<NumberInfo.SIZE_OF_NUMBER.getNumberInfo(); i++){
if(Number.charAt(i) == '0'){
throw new IllegalArgumentException();
}
}
}
}