Initial Commit

This commit is contained in:
2016-08-13 18:20:14 -05:00
commit 50f4a86fd8
408 changed files with 15301 additions and 0 deletions

View File

View File

@@ -0,0 +1,27 @@
import java.util.*;
/**
* Pangram lets you know if a string is a Pangram
* (contains all letters in the alphabet)
*/
public class Pangrams {
public static boolean isPangram(String test) {
char ch = 'a';
char[] strBytes = test.toLowerCase().toCharArray();
for(int i = 0; i < 26; i++) {
boolean foundChar = false;
for(int j = 0; j < strBytes.length; j++) {
if(strBytes[j] == ch) {
foundChar = true;
break;
}
}
ch++;
if(foundChar) {
continue;
}
return false;
}
return true;
}
}

View File

View File

@@ -0,0 +1,33 @@
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
public class PangramTest {
@Test
public void emptySentence() {
assertFalse(Pangrams.isPangram(""));
}
@Test
public void testLowercasePangram() {
assertTrue(Pangrams.isPangram("the quick brown fox jumps over the lazy dog"));
}
@Test
public void missingCharacterX() {
assertFalse(Pangrams.isPangram("a quick movement of the enemy will jeopardize five gunboats"));
}
@Test
public void mixedCaseAndPunctuation() {
assertTrue(Pangrams.isPangram("\"Five quacking Zephyrs jolt my wax bed.\""));
}
@Test
public void nonAsciiCharacters() {
assertTrue(Pangrams.isPangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich."));
}
}