Implement IntOperator.getOperand()
Co-Authored-By: td1223
This commit is contained in:
parent
bdd06f9252
commit
1e84974198
|
@ -12,6 +12,10 @@ public class IntOperator {
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOperands() {
|
||||||
|
return operands;
|
||||||
|
}
|
||||||
|
|
||||||
public int evaluate(List<Integer> arguments) {
|
public int evaluate(List<Integer> arguments) {
|
||||||
if (arguments.size() != operands) {
|
if (arguments.size() != operands) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
|
@ -25,4 +25,10 @@ public class IntOperatorTest {
|
||||||
// good
|
// good
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canGetOperatorOperandsCount() {
|
||||||
|
IntOperator intOperator = new IntOperator(2, arguments -> arguments.get(0) + arguments.get(1));
|
||||||
|
assertThat(intOperator.getOperands(), is(2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue