@Test public void whenSquareShowWithArgumentsOneAndFiveAndTwoThenPrintOutSixAndEighteenAndThirtyEight() { Square sq = new Square(1f,2f,3f); String result = null; PrintStream outConsole = System.out; try { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(outStream); System.setOut(printStream); sq.show(1,5,2); printStream.flush(); result = outStream.toString(); } finally { System.setOut(outConsole); } String sep = System.getProperty("line.separator"); assertThat(result, is(String.format("6.0%s18.0%s38.0%s", sep, sep, sep))); }
public void show (int start, int finish, int step) { for (int i = start; i <= finish; i+= step) { System.out.println(calculate(i)); } }
Square { public void show (int start, int finish, int step) { for (int i = start; i <= finish; i+= step) { System.out.println(calculate(i)); } } }
Square { public void show (int start, int finish, int step) { for (int i = start; i <= finish; i+= step) { System.out.println(calculate(i)); } } Square(float a, float b, float c); }
Square { public void show (int start, int finish, int step) { for (int i = start; i <= finish; i+= step) { System.out.println(calculate(i)); } } Square(float a, float b, float c); float calculate(int x); void show(int start, int finish, int step); }
Square { public void show (int start, int finish, int step) { for (int i = start; i <= finish; i+= step) { System.out.println(calculate(i)); } } Square(float a, float b, float c); float calculate(int x); void show(int start, int finish, int step);  }