@Test public void testContains() throws Exception { Rectangle theRectangle = new Rectangle(new Position(10, 10), new Size(20,30)); assertTrue(theRectangle.contains(new Position(11, 11))); assertTrue(theRectangle.contains(new Position(10, 10))); assertTrue(theRectangle.contains(new Position(30, 10))); assertTrue(theRectangle.contains(new Position(30, 40))); assertTrue(theRectangle.contains(new Position(10, 40))); assertFalse(theRectangle.contains(new Position(0, 0))); assertFalse(theRectangle.contains(new Position(Integer.MAX_VALUE, Integer.MAX_VALUE))); assertFalse(theRectangle.contains(new Position(Integer.MIN_VALUE, Integer.MIN_VALUE))); assertFalse(theRectangle.contains(new Position(Integer.MAX_VALUE, Integer.MIN_VALUE))); assertFalse(theRectangle.contains(new Position(Integer.MIN_VALUE, Integer.MAX_VALUE))); assertFalse(theRectangle.contains(new Position(Integer.MAX_VALUE, Integer.MAX_VALUE))); assertFalse(theRectangle.contains(new Position(Integer.MIN_VALUE, Integer.MIN_VALUE))); assertFalse(theRectangle.contains(new Position(9, 10))); assertFalse(theRectangle.contains(new Position(31, 10))); assertFalse(theRectangle.contains(new Position(31, 40))); assertFalse(theRectangle.contains(new Position(9, 40))); assertFalse(theRectangle.contains(new Position(9, 9))); assertFalse(theRectangle.contains(new Position(31, 9))); assertFalse(theRectangle.contains(new Position(31, 41))); assertFalse(theRectangle.contains(new Position(9, 41))); }
public boolean contains(Position aPosition) { return aPosition.x >= position.x && aPosition.y >= position.y && aPosition.x <= position.x + size.width && aPosition.y <= position.y + size.height; }
Rectangle implements Distributable { public boolean contains(Position aPosition) { return aPosition.x >= position.x && aPosition.y >= position.y && aPosition.x <= position.x + size.width && aPosition.y <= position.y + size.height; } }
Rectangle implements Distributable { public boolean contains(Position aPosition) { return aPosition.x >= position.x && aPosition.y >= position.y && aPosition.x <= position.x + size.width && aPosition.y <= position.y + size.height; } Rectangle();  Rectangle(Position aPosition, Size aSize); }
Rectangle implements Distributable { public boolean contains(Position aPosition) { return aPosition.x >= position.x && aPosition.y >= position.y && aPosition.x <= position.x + size.width && aPosition.y <= position.y + size.height; } Rectangle();  Rectangle(Position aPosition, Size aSize); boolean contains(Position aPosition); Rectangle newPosition(Position aNewPosition); Rectangle newSize(Size aNewSize); @Override Map<String, Object> serialize(); static Rectangle deserialize(Map<String, Object> aSerializedData); }
Rectangle implements Distributable { public boolean contains(Position aPosition) { return aPosition.x >= position.x && aPosition.y >= position.y && aPosition.x <= position.x + size.width && aPosition.y <= position.y + size.height; } Rectangle();  Rectangle(Position aPosition, Size aSize); boolean contains(Position aPosition); Rectangle newPosition(Position aNewPosition); Rectangle newSize(Size aNewSize); @Override Map<String, Object> serialize(); static Rectangle deserialize(Map<String, Object> aSerializedData); final Position position; final Size size; }