diff --git a/src/main/java/ic/doc/ReversePolishStack.java b/src/main/java/ic/doc/ReversePolishStack.java index fc0d0a0..ff6f0f9 100644 --- a/src/main/java/ic/doc/ReversePolishStack.java +++ b/src/main/java/ic/doc/ReversePolishStack.java @@ -1,7 +1,15 @@ package ic.doc; +import java.util.Stack; + public class ReversePolishStack { + private final Stack stack = new Stack<>(); + public int getSize() { - return 0; + return stack.size(); + } + + public void push(IntOperator intOperator) { + stack.push(intOperator); } } diff --git a/src/test/java/ic/doc/ReversePolishStackTest.java b/src/test/java/ic/doc/ReversePolishStackTest.java index 5fff47e..ba2bca0 100644 --- a/src/test/java/ic/doc/ReversePolishStackTest.java +++ b/src/test/java/ic/doc/ReversePolishStackTest.java @@ -12,4 +12,12 @@ public class ReversePolishStackTest { public void reversePolishStackEmptyInitially() { assertThat(reversePolishStack.getSize(), is(0)); } + + @Test + public void canPushToReversePolishStack() { + reversePolishStack.push(new IntOperator(0, args -> 1)); + assertThat(reversePolishStack.getSize(), is(1)); + reversePolishStack.push(new IntOperator(0, args -> 2)); + assertThat(reversePolishStack.getSize(), is(2)); + } }