@Test public void containsTest() { Rectangle rectangle = create(1, 2, 3, 4); Assert.assertTrue(rectangle.contains(new Point(1, 2))); Assert.assertTrue(rectangle.contains(new Point(1, 4))); Assert.assertTrue(rectangle.contains(new Point(3, 2))); Assert.assertTrue(rectangle.contains(new Point(3, 4))); Assert.assertTrue(rectangle.contains(new Point(2, 3))); Assert.assertFalse(rectangle.contains(new Point(0, 0))); Assert.assertFalse(rectangle.contains(new Point(1, 1))); Assert.assertFalse(rectangle.contains(new Point(4, 4))); Assert.assertFalse(rectangle.contains(new Point(5, 5))); }
public boolean contains(Point point) { return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y; }
Rectangle implements Serializable { public boolean contains(Point point) { return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y; } }
Rectangle implements Serializable { public boolean contains(Point point) { return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y; } Rectangle(double left, double top, double right, double bottom); }
Rectangle implements Serializable { public boolean contains(Point point) { return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y; } Rectangle(double left, double top, double right, double bottom); boolean contains(Point point); Rectangle enlarge(double left, double top, double right, double bottom); Rectangle envelope(double padding); @Override boolean equals(Object obj); Point getCenter(); double getCenterX(); double getCenterY(); double getHeight(); double getWidth(); @Override int hashCode(); boolean intersects(Rectangle rectangle); boolean intersectsCircle(double pointX, double pointY, double radius); Rectangle shift(Point origin); @Override String toString(); }
Rectangle implements Serializable { public boolean contains(Point point) { return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y; } Rectangle(double left, double top, double right, double bottom); boolean contains(Point point); Rectangle enlarge(double left, double top, double right, double bottom); Rectangle envelope(double padding); @Override boolean equals(Object obj); Point getCenter(); double getCenterX(); double getCenterY(); double getHeight(); double getWidth(); @Override int hashCode(); boolean intersects(Rectangle rectangle); boolean intersectsCircle(double pointX, double pointY, double radius); Rectangle shift(Point origin); @Override String toString(); final double bottom; final double left; final double right; final double top; }