Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // a op b == c
- class Equation {
- final Operand a, b, c;
- final Operation op;
- Equation(Operand a, Operand b, Operand c, Operation op) {
- this.a = a;
- this.b = b;
- this.c = c;
- this.op = op;
- }
- static Equation createRandom(Random r) {
- Operand[] abc = new Operand[3];
- int missingIndex = r.newInt(3);
- for (int i = 0; i < abc.length; i++) {
- abc[i] = i == missingIndex
- ? new Missing()
- : new Operand(r.nextInt());
- }
- return new Equation(abc[0], abc[1], abc[2], new PlusOperation());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement