@Test public void shouldReturnTrueIfInputStringIsEmpty(){ assertTrue(palindromes.evaluate("")); }
public boolean evaluate(String word) { if (word == null) { throw new IllegalArgumentException("You can't pass a null String as input."); } boolean result = true; int length = word.length(); for (int i = 0; i < length / 2; i++) { if (word.charAt(i) != word.charAt(length - 1 - i)) { result = false; break; } } return result; }
Palindromes { public boolean evaluate(String word) { if (word == null) { throw new IllegalArgumentException("You can't pass a null String as input."); } boolean result = true; int length = word.length(); for (int i = 0; i < length / 2; i++) { if (word.charAt(i) != word.charAt(length - 1 - i)) { result = false; break; } } return result; } }
Palindromes { public boolean evaluate(String word) { if (word == null) { throw new IllegalArgumentException("You can't pass a null String as input."); } boolean result = true; int length = word.length(); for (int i = 0; i < length / 2; i++) { if (word.charAt(i) != word.charAt(length - 1 - i)) { result = false; break; } } return result; }  }
Palindromes { public boolean evaluate(String word) { if (word == null) { throw new IllegalArgumentException("You can't pass a null String as input."); } boolean result = true; int length = word.length(); for (int i = 0; i < length / 2; i++) { if (word.charAt(i) != word.charAt(length - 1 - i)) { result = false; break; } } return result; }  boolean evaluate(String word); }
Palindromes { public boolean evaluate(String word) { if (word == null) { throw new IllegalArgumentException("You can't pass a null String as input."); } boolean result = true; int length = word.length(); for (int i = 0; i < length / 2; i++) { if (word.charAt(i) != word.charAt(length - 1 - i)) { result = false; break; } } return result; }  boolean evaluate(String word);  }