ocp string calculator kata

Download OCP String Calculator kata

If you can't read please download the document

Upload: kevin-rutherford

Post on 16-Apr-2017

579 views

Category:

Documents


2 download

TRANSCRIPT

OCP String Calculator KataUsing the OCP rules, write a very simple
string calculator using the following test template:

public class CalculatorTester { @Test public void sampleTest() { Calculator calculator = new CalculatorFactory().create(); assertEquals(4, calculator.evaluate("2 + 2")); }}

OCP String Calculator KataThe tests are:

" " -> 0"234" -> 234"6 + 3" -> 9"12 + 34" -> 46"6 - 3" -> 3"18 - 4" -> 14"6 * 3" -> 18"5 * 22" -> 110"6 / 3" -> 2"36 / 12" -> 3

You can assume that:

A single space char separates the operator from the numbers.

Only integer arithmetic is to be supported.

OCP String Calculator KataAdditional challenges:

"18 - 4 + 3" -> 17"18 - 4 * 3" -> 6"18 - (4 + 3)" -> 11

Only integer arithmetic is to be supported.

Click to edit the title text format