@Test public void shouldReturnTrueIfBothWordsAreEmpty() { assertTrue(areAnagrams.check("", "")); }
public boolean check(String a, String b) { if (a == null || b == null) { throw new IllegalArgumentException("You can't use null Strings as input."); } if (a.length() != b.length()) { return false; } int[] lettersA = getLettersAsArray(a); int[] lettersB = getLettersAsArray(b); int valuesA = getSumOfArray(lettersA); int valuesB = getSumOfArray(lettersB); return valuesA == valuesB; }
AreAnagrams { public boolean check(String a, String b) { if (a == null || b == null) { throw new IllegalArgumentException("You can't use null Strings as input."); } if (a.length() != b.length()) { return false; } int[] lettersA = getLettersAsArray(a); int[] lettersB = getLettersAsArray(b); int valuesA = getSumOfArray(lettersA); int valuesB = getSumOfArray(lettersB); return valuesA == valuesB; } }
AreAnagrams { public boolean check(String a, String b) { if (a == null || b == null) { throw new IllegalArgumentException("You can't use null Strings as input."); } if (a.length() != b.length()) { return false; } int[] lettersA = getLettersAsArray(a); int[] lettersB = getLettersAsArray(b); int valuesA = getSumOfArray(lettersA); int valuesB = getSumOfArray(lettersB); return valuesA == valuesB; }  }
AreAnagrams { public boolean check(String a, String b) { if (a == null || b == null) { throw new IllegalArgumentException("You can't use null Strings as input."); } if (a.length() != b.length()) { return false; } int[] lettersA = getLettersAsArray(a); int[] lettersB = getLettersAsArray(b); int valuesA = getSumOfArray(lettersA); int valuesB = getSumOfArray(lettersB); return valuesA == valuesB; }  boolean check(String a, String b); }
AreAnagrams { public boolean check(String a, String b) { if (a == null || b == null) { throw new IllegalArgumentException("You can't use null Strings as input."); } if (a.length() != b.length()) { return false; } int[] lettersA = getLettersAsArray(a); int[] lettersB = getLettersAsArray(b); int valuesA = getSumOfArray(lettersA); int valuesB = getSumOfArray(lettersB); return valuesA == valuesB; }  boolean check(String a, String b);  }