-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolutionTree.java
More file actions
79 lines (79 loc) · 1.9 KB
/
SolutionTree.java
File metadata and controls
79 lines (79 loc) · 1.9 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
public class SolutionTree
{
public Sequent sequent;
public SolutionTree lChild, rChild;
public String step;
public int solved; // 0 not atom 1 solved 2 unsolved
public SolutionTree()
{
sequent = null;
lChild = null;
rChild = null;
step = "";
solved = 2;
}
public SolutionTree(Sequent sequent)
{
this.sequent = sequent;
step = "";
solved = 0;
}
public SolutionTree(Sequent sequent, String step, int b)
{
this.sequent = sequent;
this.step = step;
solved = b;
}
public SolutionTree(int b)
{
sequent = null;
lChild = null;
rChild = null;
step = "";
solved = b;
}
public static void print(SolutionTree st)
{
print(st, 0);
}
private static void print(SolutionTree st, int level)
{
for(int i = 0; i < level; i++)
{
System.out.print(" ");
}
System.out.println(st.sequent + "\t\t\t\t" + st.step);
if(st.solved == 1)
{
System.out.print("Solved");
}
else if(st.solved == 2)
{
System.out.print("Cannot solve, exiting...");
System.exit(0);
}
else
{
if(st.rChild == null)
{
print(st.lChild, level);
}
else
{
for(int i = 0; i < level; i++)
{
System.out.print(" ");
}
System.out.println("Left Child:");
print(st.lChild, level+1);
for(int i = 0; i < level; i++)
{
System.out.print(" ");
}
System.out.println("Right Child");
print(st.rChild, level+1);
}
}
System.out.println();
}
}