@Test public void shouldTransformPositiveIntegersWithJustOneDigit() { assertEquals("7", intToString.transform(7)); }
public String transform(int number) { boolean isNegative = false; StringBuilder sb = new StringBuilder(); if (number == 0) { return "0"; } else if (number < 0) { isNegative = true; } number = Math.abs(number); while (number > 0) { sb.append(number % 10); number /= 10; } if (isNegative) { sb.append("-"); } return sb.reverse().toString(); }
IntToString { public String transform(int number) { boolean isNegative = false; StringBuilder sb = new StringBuilder(); if (number == 0) { return "0"; } else if (number < 0) { isNegative = true; } number = Math.abs(number); while (number > 0) { sb.append(number % 10); number /= 10; } if (isNegative) { sb.append("-"); } return sb.reverse().toString(); } }
IntToString { public String transform(int number) { boolean isNegative = false; StringBuilder sb = new StringBuilder(); if (number == 0) { return "0"; } else if (number < 0) { isNegative = true; } number = Math.abs(number); while (number > 0) { sb.append(number % 10); number /= 10; } if (isNegative) { sb.append("-"); } return sb.reverse().toString(); }  }
IntToString { public String transform(int number) { boolean isNegative = false; StringBuilder sb = new StringBuilder(); if (number == 0) { return "0"; } else if (number < 0) { isNegative = true; } number = Math.abs(number); while (number > 0) { sb.append(number % 10); number /= 10; } if (isNegative) { sb.append("-"); } return sb.reverse().toString(); }  String transform(int number); }
IntToString { public String transform(int number) { boolean isNegative = false; StringBuilder sb = new StringBuilder(); if (number == 0) { return "0"; } else if (number < 0) { isNegative = true; } number = Math.abs(number); while (number > 0) { sb.append(number % 10); number /= 10; } if (isNegative) { sb.append("-"); } return sb.reverse().toString(); }  String transform(int number);  }