O'Reilly logo

Test-Driven Java Development - Second Edition by Viktor Farcic, Alex Garcia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required