Advertisement
SirBaconBitz

containsRectangle

Dec 19th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. public boolean contains(int x, int y) {
  2.     boolean xIn = (this.x < x) && (x < this.x + width);
  3.     boolean yIn = (this.y < y) && (y < this.y + height);
  4.     return xIn && yIn;
  5. }
  6.  
  7. public boolean contains(Point p) {
  8.     boolean xIn = (this.x < p.getX()) && (p.getX() < this.x + width);
  9.     boolean yIn = (this.y < p.getY()) && (p.getY() < this.y + height);
  10.     return xIn && yIn;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement