Skip to content

Commit

Permalink
Adding solution
Browse files Browse the repository at this point in the history
  • Loading branch information
josdem committed May 7, 2024
1 parent f103443 commit 1e5ab20
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.josdem.kata;

import java.util.List;
import java.util.stream.Collectors;

public class PhoneNumberGenerator {
public String format(List<Integer> 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();
}
}

0 comments on commit 1e5ab20

Please sign in to comment.