From 1e8497419893990289a872ac174216896d05abaf Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 5 Nov 2024 17:01:05 +0000 Subject: [PATCH] Implement IntOperator.getOperand() Co-Authored-By: td1223 --- src/main/java/ic/doc/IntOperator.java | 4 ++++ src/test/java/ic/doc/IntOperatorTest.java | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/ic/doc/IntOperator.java b/src/main/java/ic/doc/IntOperator.java index df24beb..698c16c 100644 --- a/src/main/java/ic/doc/IntOperator.java +++ b/src/main/java/ic/doc/IntOperator.java @@ -12,6 +12,10 @@ public class IntOperator { this.operator = operator; } + public int getOperands() { + return operands; + } + public int evaluate(List arguments) { if (arguments.size() != operands) { throw new IllegalArgumentException( diff --git a/src/test/java/ic/doc/IntOperatorTest.java b/src/test/java/ic/doc/IntOperatorTest.java index 796aa8c..b0244d3 100644 --- a/src/test/java/ic/doc/IntOperatorTest.java +++ b/src/test/java/ic/doc/IntOperatorTest.java @@ -25,4 +25,10 @@ public class IntOperatorTest { // good } } + + @Test + public void canGetOperatorOperandsCount() { + IntOperator intOperator = new IntOperator(2, arguments -> arguments.get(0) + arguments.get(1)); + assertThat(intOperator.getOperands(), is(2)); + } }