Requirements

We are going to obviate how the expressions are read so that we can focus on solving the problem. Furthermore, we are going to work only with positive integers to simplify the problem, although it shouldn't be very difficult to accept floats or doubles as well. In order to solve this kata, we are asked to fulfill only the following two requirements:

  • On invalid input (not a RPN), an error message should be thrown
  • It gets an arithmetic expression written using RPN and computes the result

The following code snippet is a small scaffold for us to start our project upon:

public class ReversePolishNotation {
int compute(String expression) {
return 0;
}
}

public class NotReversePolishNotationError extends RuntimeException {
public NotReversePolishNotationError() {
super("Not a Reverse Polish Notation");
}
}

With the preceding code fragment as the starting point, we are going to proceed, breaking down the requirements into smaller specifications that can be tackled one by one.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.18