Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pangram: add starter implementation and make object-based #344

Merged
merged 4 commits into from
Mar 7, 2017
Merged
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import java.util.Arrays;
import java.util.stream.Collectors;

public class Pangrams {
public class PangramChecker {
private static final int alphaLength = 26;

public static boolean isPangram(String input){
return Arrays.stream(input.replaceAll("[^a-zA-Z]","").toLowerCase().split(""))
public boolean isPangram(String input) {
return Arrays.stream(input.replaceAll("[^a-zA-Z]", "")
.toLowerCase()
.split(""))
.collect(Collectors.toSet())
.size() == alphaLength;
}
Expand Down
Empty file.
6 changes: 6 additions & 0 deletions exercises/pangram/src/main/java/PangramChecker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class PangramChecker {

public boolean isPangram(String input) {
throw new UnsupportedOperationException("Method has not been implemented yet.");
}
}
82 changes: 82 additions & 0 deletions exercises/pangram/src/test/java/PangramCheckerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class PangramCheckerTest {
private PangramChecker pangramChecker;

@Before
public void setup() {
pangramChecker = new PangramChecker();
}


@Test
public void emptySentenceIsNotPangram() {
assertFalse(pangramChecker.isPangram(""));
}

@Ignore
@Test
public void pangramWithOnlyLowerCaseLettersIsRecognizedAsPangram() {
assertTrue(pangramChecker.isPangram("the quick brown fox jumps over the lazy dog"));
}

@Ignore
@Test
public void phraseMissingCharacterXIsNotPangram() {
assertFalse(pangramChecker.isPangram("a quick movement of the enemy will jeopardize five gunboats"));
}

@Ignore
@Test
public void anotherPhraseMissingCharacterXIsNotPangram() {
assertFalse(pangramChecker.isPangram("the quick brown fish jumps over the lazy dog"));
}

@Ignore
@Test
public void pangramWithUnderscoresIsRecognizedAsPangram() {
assertTrue(pangramChecker.isPangram("\"the_quick_brown_fox_jumps_over_the_lazy_dog\""));
}

@Ignore
@Test
public void pangramWithNumbersIsRecognizedAsPangram() {
assertTrue(pangramChecker.isPangram("\"the 1 quick brown fox jumps over the 2 lazy dogs\""));
}

@Ignore
@Test
public void phraseWithMissingLettersReplacedByNumbersIsNotPangram() {
assertFalse(pangramChecker.isPangram("\"7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog\""));
}

@Ignore
@Test
public void pangramWithMixedCaseAndPunctuationIsRecognizedAsPangram() {
assertTrue(pangramChecker.isPangram("\"Five quacking Zephyrs jolt my wax bed.\""));
}

@Ignore
@Test
public void pangramWithNonAsciiCharactersIsRecognizedAsPangram() {
assertTrue(pangramChecker.isPangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich."));
}


@Ignore
@Test
public void panagramInAlphabetOtherThanAsciiIsNotRecognizedAsPangram() {
assertFalse(pangramChecker.isPangram("Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства."));
}

@Ignore
@Test
public void upperAndLowerCaseVersionsOfTheSameCharacterShouldNotBeCountedSeparately() {
assertFalse(pangramChecker.isPangram("the quick brown fox jumped over the lazy FOX"));
}
}
75 changes: 0 additions & 75 deletions exercises/pangram/src/test/java/PangramsTest.java

This file was deleted.