@Test public void shouldReturnFalseIfAnObjectOtherThanAnIntegerIsSupplied() throws Exception { Range<Integer> range = new IntegerRange(0, 10, 3); Boolean contained = range.contains("hello"); assertThat(contained, is(false)); }
@Override public boolean contains(Object other) { if (other instanceof Integer) { int valueToFind = (Integer) other; for (int valueInRange : this) { if (valueInRange == valueToFind) { return true; } } } return false; }
IntegerRange implements Range<Integer> { @Override public boolean contains(Object other) { if (other instanceof Integer) { int valueToFind = (Integer) other; for (int valueInRange : this) { if (valueInRange == valueToFind) { return true; } } } return false; } }
IntegerRange implements Range<Integer> { @Override public boolean contains(Object other) { if (other instanceof Integer) { int valueToFind = (Integer) other; for (int valueInRange : this) { if (valueInRange == valueToFind) { return true; } } } return false; } IntegerRange(Integer start, Integer end);  IntegerRange(Integer start, Integer end, Integer step); }
IntegerRange implements Range<Integer> { @Override public boolean contains(Object other) { if (other instanceof Integer) { int valueToFind = (Integer) other; for (int valueInRange : this) { if (valueInRange == valueToFind) { return true; } } } return false; } IntegerRange(Integer start, Integer end);  IntegerRange(Integer start, Integer end, Integer step); @Override boolean contains(Object other); @Override Integer getStart(); @Override Integer getEnd(); @Override Integer getStep(); @Override Iterator<Integer> iterator(); }
IntegerRange implements Range<Integer> { @Override public boolean contains(Object other) { if (other instanceof Integer) { int valueToFind = (Integer) other; for (int valueInRange : this) { if (valueInRange == valueToFind) { return true; } } } return false; } IntegerRange(Integer start, Integer end);  IntegerRange(Integer start, Integer end, Integer step); @Override boolean contains(Object other); @Override Integer getStart(); @Override Integer getEnd(); @Override Integer getStep(); @Override Iterator<Integer> iterator();  }