File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/java/edu/thoughtworks/training
test/java/edu/thoughtworks/training Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 22
33public class FizzBuzz {
44 public String represent (int number ) {
5- if (number %3 == 0 ) return "Fizz" ;
6- else return "Buzz" ;
5+ String representation = new String ();
6+ if (number % 3 == 0 ) representation += "Fizz" ;
7+ if (number % 5 == 0 ) representation += "Buzz" ;
8+ return representation ;
79 }
810}
Original file line number Diff line number Diff line change @@ -26,4 +26,12 @@ public void returnFizzBuzzWhenNumberIsBothDivisibleBy3And5() {
2626 assertThat ("FizzBuzz doesn't return FizzBuzz on multiples of 3 and 5" ,
2727 fizzBuzz .represent (15 ), is ("FizzBuzz" ));
2828 }
29+
30+ @ Test
31+ public void returnItselfWhenNumberNotDivisibleBy3Or5 () {
32+ FizzBuzz fizzBuzz = new FizzBuzz ();
33+ assertThat ("FizzBuzz doesn't return number when number is not divisible by 3 or 5" ,
34+ fizzBuzz .represent (8 ), is ("8" ));
35+
36+ }
2937}
You can’t perform that action at this time.
0 commit comments