feat: update structure
This commit is contained in:
25
cs2030s/labs/Lab6/Not.java
Normal file
25
cs2030s/labs/Lab6/Not.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Represents the Not type, a conditional which inverts the given input.
|
||||
*/
|
||||
class Not implements Cond {
|
||||
private Cond val;
|
||||
|
||||
public Not(Cond val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eval() {
|
||||
return !this.val.eval();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "!(" + this.val + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cond neg() {
|
||||
return this.val;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user