-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathGameInputException.java
More file actions
38 lines (27 loc) · 944 Bytes
/
GameInputException.java
File metadata and controls
38 lines (27 loc) · 944 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
package exception;
import message.GameMessage;
public class GameInputException {
//private static GameInputException defaultGameInputException;
public GameInputException() {
}
public void validateNameLength(String[] names) {
for(String name : names) {
if(name.length() > 5) {
throw new IllegalArgumentException(GameMessage.nameError.getMessage());
}
}
}
public void validateNumber(String number) {
if(!number.matches(GameMessage.REGEX.getMessage())) {
throw new IllegalArgumentException(GameMessage.countError.getMessage());
}
}
public void validateNumberZero(String number) {
if(number.length() > 1 && number.charAt(0) == '0') {
throw new IllegalArgumentException(GameMessage.countError.getMessage());
}
}
public void close() {
//defaultGameInputException = null;
}
}