added binary expressions
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
package worms.programs;
|
||||
|
||||
public abstract class BinaryExpression<L, R> implements Expression {
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.DoubleBinaryOperator;
|
||||
|
||||
protected final L left;
|
||||
protected final R right;
|
||||
public abstract class BinaryExpression implements Expression {
|
||||
|
||||
public BinaryExpression(L left, R right) {
|
||||
protected final Object left;
|
||||
protected final Object right;
|
||||
|
||||
public BinaryExpression(Object left, Object right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Object execute(BinaryOperator op) {
|
||||
return op.apply(this.left, this.right);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user