Implement IntOperator.getOperand()

Co-Authored-By: td1223
This commit is contained in:
Gleb Koval 2024-11-05 17:01:05 +00:00
parent bdd06f9252
commit 1e84974198
Signed by: cyclane
GPG Key ID: 15E168A8B332382C
2 changed files with 10 additions and 0 deletions

View File

@ -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(

View File

@ -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));
}
} }