-
Notifications
You must be signed in to change notification settings - Fork 0
/
Val.java
70 lines (59 loc) · 1.4 KB
/
Val.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
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
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Val Represent the boolean true and false expressions.
* @author Yossi Maatook.
*/
public class Val implements Expression {
private Boolean value;
/**
* Constructor.
* @param v - the boolean forming the val expression.
*/
public Val(Boolean v) {
this.value = v;
}
@Override
public Boolean evaluate(Map<String, Boolean> assignment) throws Exception {
return this.value;
}
@Override
public Boolean evaluate() throws Exception {
return this.value;
}
@Override
public List<String> getVariables() {
return new ArrayList<>();
}
@Override
public String toString() {
if (this.value) {
return ("T");
}
return ("F");
}
@Override
public Expression assign(String var, Expression expression) {
return new Val(this.value);
}
/**
* Returns the boolean value of the var.
* @return the boolean value of the var.
*/
public Boolean getValue() {
return this.value;
}
@Override
public Expression nandify() {
return this;
}
@Override
public Expression norify() {
return this;
}
@Override
public Expression simplify() {
return this;
}
}