Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions clean-code-challanges/src/main/java/Acronym.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import java.util.Arrays;
import java.util.stream.Collectors;

/**
* Convert a phrase to its acronym.
*
Expand All @@ -6,13 +9,19 @@
* Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).
*/
class Acronym {
private final String cleanedPhrase;
private final String whitespaces = "\\s";

Acronym(String phrase) {

phrase = phrase.replaceAll("-", " ");
this.cleanedPhrase = phrase.replaceAll("[^A-Za-z" + whitespaces + "]", "");
}

String get() {
return null;
return Arrays.stream(cleanedPhrase.split(whitespaces))
.filter(s -> !s.isEmpty())
.map(s -> s.toUpperCase().charAt(0))
.map(Object::toString)
.collect(Collectors.joining());
}

}
1 change: 0 additions & 1 deletion clean-code-challanges/src/test/java/AcronymTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import static org.junit.Assert.assertEquals;

@Ignore
public class AcronymTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -8,6 +9,7 @@
import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
@Ignore
public class PigLatinTranslatorTest {

private String englishPhrase;
Expand Down