21 lines
507 B
Java
21 lines
507 B
Java
package worms.programs;
|
|
|
|
import java.util.function.BinaryOperator;
|
|
import java.util.function.DoubleBinaryOperator;
|
|
|
|
public abstract class BinaryExpression implements Expression {
|
|
|
|
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);
|
|
}
|
|
}
|