Skip to content

Commit

Permalink
pangram: add starter implementation and make object-based (#344)
Browse files Browse the repository at this point in the history
Pangrams is currently the third exercise in the new ordering therefore
it should have a starter implementation.

* make object-orientated
* add starter implementation
* rename class to PangramChecker
  • Loading branch information
FridaTveit authored and jtigger committed Mar 7, 2017
1 parent 9f8244f commit 99f4a1d
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 78 deletions.
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.

0 comments on commit 99f4a1d

Please sign in to comment.