0

Im trying to to create a simple 4 function calculator using a jump table without switch case or if/else statements. I understand I can create the jump table via function pointers but I am kindda blanking out. I've started with the addition and subtraction part of the program but am trying to grasp the design/strategy to use. I am also getting an error when putting the method in the array, so far this is what i have:

```
public class Calculator {
public abstract class Functor{
abstract double Compute();
}
class Addition extends Functor
{
double op1, op2;
public Addition(double op1, double op2){
this.op1 = op1;
this.op2 = op2;
}
public double Compute(){ return op1 + op2;}
}
class Subtraction extends Functor
{
double op1, op2;
public Subtraction(double op1, double op2)
{
this.op1 = op1;
this.op2 = op2;
}
public double Compute(){ return op1 - op2;}
}
public static void main(String[] args) {
Functor add = new Addition(); // Seems to be a problem here
Functor [] jumpArray = new Functor [256];
}
}
```