-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmwgcCompute.java
More file actions
60 lines (48 loc) · 1.19 KB
/
mwgcCompute.java
File metadata and controls
60 lines (48 loc) · 1.19 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
import java.util.Scanner;
public class mwgcCompute {
static Scanner sc = new Scanner(System.in);
final int[][] lookUp = {
{10, 10, 1, 10},
{2, 10, 0, 10},
{1, 4, 10, 3},
{10, 10, 5, 2},
{10, 2, 6, 10},
{10, 7, 3, 10},
{10, 10, 4, 7},
{8, 5, 10, 6},
{7, 10, 9, 10},
{10, 10, 8, 10},
{10, 10, 10, 10}
};
static enum item { m, w, g, c};
int currentState;
int acceptedState;
String input;
public mwgcCompute() {
currentState = 0;
acceptedState = 9;
input = "";
}
public void setInput(String userInput) {
input = userInput;
}
public boolean getResult() {
boolean output = false;
for(int i = 0; i < input.length(); i++) {
String inputSub = input.substring(i, i + 1);
currentState = lookUp[currentState][ item.valueOf(inputSub).ordinal() ];
}
output = currentState == acceptedState;
return output;
}
public static void main(String[] args) {
mwgcCompute compute = new mwgcCompute();
System.out.println("Please input your proposed solution:");
compute.setInput(sc.nextLine());
if(compute.getResult()) {
System.out.println("This is a solution.");
} else {
System.out.println("This is not a solution.");
}
}
}