@Test public void testIsAnagram() { assertTrue(AnagramDictionary.isAnagram("cat", "act")); assertTrue(AnagramDictionary.isAnagram("spots", "stops")); assertFalse(AnagramDictionary.isAnagram("cat", "dog")); assertFalse(AnagramDictionary.isAnagram("cat", "")); }
@VisibleForTesting static boolean isAnagram(String first, String second) { if (first == null || first.equals("") || second == null || second.equals("")) { return false; } if (first.length() != second.length()) { return false; } return sortLetters(first).equals(sortLetters(second)); }
AnagramDictionary { @VisibleForTesting static boolean isAnagram(String first, String second) { if (first == null || first.equals("") || second == null || second.equals("")) { return false; } if (first.length() != second.length()) { return false; } return sortLetters(first).equals(sortLetters(second)); } }
AnagramDictionary { @VisibleForTesting static boolean isAnagram(String first, String second) { if (first == null || first.equals("") || second == null || second.equals("")) { return false; } if (first.length() != second.length()) { return false; } return sortLetters(first).equals(sortLetters(second)); } AnagramDictionary(InputStream wordListStream); @VisibleForTesting  AnagramDictionary(String[] words); }
AnagramDictionary { @VisibleForTesting static boolean isAnagram(String first, String second) { if (first == null || first.equals("") || second == null || second.equals("")) { return false; } if (first.length() != second.length()) { return false; } return sortLetters(first).equals(sortLetters(second)); } AnagramDictionary(InputStream wordListStream); @VisibleForTesting  AnagramDictionary(String[] words); boolean isGoodWord(String word, String base); ArrayList<String> getAnagrams(String targetWord); ArrayList<String> getAnagramsWithOneMoreLetter(String word); String pickGoodStarterWord(); }
AnagramDictionary { @VisibleForTesting static boolean isAnagram(String first, String second) { if (first == null || first.equals("") || second == null || second.equals("")) { return false; } if (first.length() != second.length()) { return false; } return sortLetters(first).equals(sortLetters(second)); } AnagramDictionary(InputStream wordListStream); @VisibleForTesting  AnagramDictionary(String[] words); boolean isGoodWord(String word, String base); ArrayList<String> getAnagrams(String targetWord); ArrayList<String> getAnagramsWithOneMoreLetter(String word); String pickGoodStarterWord();  }