-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathState.java
43 lines (34 loc) · 820 Bytes
/
State.java
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
public class State {
private boolean IS_DEFAULT = false;
private boolean IS_ACCEPT = false;
private String name;
private String status;
/**
* State constructor which sets its name and status.
* Throws an InputException if the status provided is invalid.
**/
public State(String name, String status) throws InputException {
this.name = name;
if(status.equals(""))
IS_DEFAULT = true;
else if(status.equals("+"))
IS_ACCEPT = true;
else if(status.equals("-"))
IS_ACCEPT = false;
else
throw new InputException("Error: status provided is invalid");
this.status = status;
}
public String getName() {
return name;
}
public String getStatus() {
return status;
}
public boolean isDefault() {
return IS_DEFAULT;
}
public boolean isAcceptState() {
return IS_ACCEPT;
}
}