-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCertify.java
More file actions
61 lines (60 loc) · 1.85 KB
/
Copy pathCertify.java
File metadata and controls
61 lines (60 loc) · 1.85 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
package tracker;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class Certify {
private final List<String> rawCopy;
private boolean matches;
private int id, java, dsa, db, spring;
public int getId() {
return id;
}
public int getJava() {
return java;
}
public int getDsa() {
return dsa;
}
public int getDatabase() {
return db;
}
public int getSpring() {
return spring;
}
Certify(List<String> rawInput) {
rawCopy = new ArrayList<>(rawInput);
String rawCopyString = rawCopy.toString()
.replaceAll("\\[", "")
.replaceAll(",","")
.replaceAll("]","");
matches = Pattern.matches("[^-]\\d* \\d* \\d* \\d* \\d*", rawCopyString);
}
private int inputErrorChecks(){
int errorCode = 0;
if(rawCopy.size() == 1 && !rawCopy.get(0).equalsIgnoreCase("back")) {
errorCode = 101;
//System.out.println("Incorrect points format."); // changed from: "incorrect credentials"
} else if(rawCopy.size() != 5 ) {
errorCode = 102;
}
return errorCode;
}
private void assign() {
int ID = 0, JAVA = 1, DSA = 2, DB = 3, SPRING = 4;
id = Integer.parseInt(rawCopy.get(ID));
java = Integer.parseInt(rawCopy.get(JAVA));
dsa = Integer.parseInt(rawCopy.get(DSA));
db = Integer.parseInt(rawCopy.get(DB));
spring = Integer.parseInt(rawCopy.get(SPRING));
}
public boolean run() {
int errorCode = inputErrorChecks();
if(errorCode == 0 && matches) {
assign();
return true;
} else {
System.out.println("Incorrect points format."); // changed from: "incorrect credentials"
return false;
}
}
}