diff --git a/simple-algorithms/create-phone-number/src/main/java/com/josdem/kata/PhoneNumberGenerator.java b/simple-algorithms/create-phone-number/src/main/java/com/josdem/kata/PhoneNumberGenerator.java index b9ce156..6c6d758 100644 --- a/simple-algorithms/create-phone-number/src/main/java/com/josdem/kata/PhoneNumberGenerator.java +++ b/simple-algorithms/create-phone-number/src/main/java/com/josdem/kata/PhoneNumberGenerator.java @@ -1,9 +1,13 @@ package com.josdem.kata; import java.util.List; +import java.util.stream.Collectors; public class PhoneNumberGenerator { public String format(List numbers) { - return numbers.toString(); + StringBuilder sb = new StringBuilder(); + String numbersAsString = numbers.stream().map(String::valueOf).collect(Collectors.joining("")); + sb.append(numbersAsString).insert(0, '(').insert(4, ')').insert(5, ' ').insert(9, '-'); + return sb.toString(); } }