@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullStringsAsInput() { contains.evaluate(null, null); }
public boolean evaluate(String w1, String w2) { if (w1 == null || w2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } boolean contains = false; for (int i = 0; i < w2.length() - 1; i++) { if (w2.charAt(i) == w1.charAt(0)) { for (int j = 0; j < w1.length(); j++) { if (w1.charAt(j) == w2.charAt(i + j) && j == w1.length() - 1) { contains = true; break; } } } } return contains; }
Contains { public boolean evaluate(String w1, String w2) { if (w1 == null || w2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } boolean contains = false; for (int i = 0; i < w2.length() - 1; i++) { if (w2.charAt(i) == w1.charAt(0)) { for (int j = 0; j < w1.length(); j++) { if (w1.charAt(j) == w2.charAt(i + j) && j == w1.length() - 1) { contains = true; break; } } } } return contains; } }
Contains { public boolean evaluate(String w1, String w2) { if (w1 == null || w2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } boolean contains = false; for (int i = 0; i < w2.length() - 1; i++) { if (w2.charAt(i) == w1.charAt(0)) { for (int j = 0; j < w1.length(); j++) { if (w1.charAt(j) == w2.charAt(i + j) && j == w1.length() - 1) { contains = true; break; } } } } return contains; }  }
Contains { public boolean evaluate(String w1, String w2) { if (w1 == null || w2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } boolean contains = false; for (int i = 0; i < w2.length() - 1; i++) { if (w2.charAt(i) == w1.charAt(0)) { for (int j = 0; j < w1.length(); j++) { if (w1.charAt(j) == w2.charAt(i + j) && j == w1.length() - 1) { contains = true; break; } } } } return contains; }  boolean evaluate(String w1, String w2); }
Contains { public boolean evaluate(String w1, String w2) { if (w1 == null || w2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } boolean contains = false; for (int i = 0; i < w2.length() - 1; i++) { if (w2.charAt(i) == w1.charAt(0)) { for (int j = 0; j < w1.length(); j++) { if (w1.charAt(j) == w2.charAt(i + j) && j == w1.length() - 1) { contains = true; break; } } } } return contains; }  boolean evaluate(String w1, String w2);  }