feat: update structure
This commit is contained in:
25
cs2030s/labs/Lab6/Bool.java
Normal file
25
cs2030s/labs/Lab6/Bool.java
Normal file
@@ -0,0 +1,25 @@
|
||||
import cs2030s.fp.Constant;
|
||||
import cs2030s.fp.Memo;
|
||||
|
||||
class Bool implements Cond {
|
||||
private Memo<Boolean> val;
|
||||
|
||||
public Bool(Constant<Boolean> val) {
|
||||
this.val = Memo.from(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eval() {
|
||||
return this.val.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.val.toString().substring(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cond neg() {
|
||||
return new Not(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user