18 lines
291 B
JavaScript
18 lines
291 B
JavaScript
class Rectangle {
|
|
constructor(x, y, width, height) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.width = width;
|
|
this.height = height;
|
|
}
|
|
|
|
contains(x, y) {
|
|
return (
|
|
x > this.x &&
|
|
x < this.x + this.width &&
|
|
y > this.y &&
|
|
y < this.y + this.height
|
|
);
|
|
}
|
|
}
|