-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRule.java
More file actions
57 lines (50 loc) · 1.31 KB
/
Rule.java
File metadata and controls
57 lines (50 loc) · 1.31 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
import java.util.ArrayList;
public class Rule {
public static final int AND = 1;
public static final int OR = 2;
public static final int IMPLIES = 3;
public static final int IFF = 4;
ArrayList<Quantifier> quantifiers = new ArrayList<>();
boolean negated;
//boolean leftRuleNot;
//boolean rightRuleNot;
Fact fact;
Rule leftRule;
Rule rightRule;
boolean justFact = false;
int connector;
public Rule() {
}
public Rule(Fact fact) {
this.fact = fact;
justFact = true;
}
public void printRule() {
if (justFact) {
fact.printFact();
return;
}
for (Quantifier quantifier : quantifiers) {
quantifier.printQuantifier();
}
System.out.print(" (");
leftRule.printRule();
System.out.print(") ");
switch (connector) {
case OR:
System.out.print("OR");
break;
case AND:
System.out.print("AND");
break;
case IFF:
System.out.print("IFF");
break;
case IMPLIES:
System.out.print("IMPLIES");
}
System.out.print(" (");
rightRule.printRule();
System.out.println(")");
}
}