class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class Rectangle {
constructor(topLeft, bottomRight) {
this.topLeft = topLeft;
this.bottomRight = bottomRight;
}
}
function isPointInsideRectangle(p, rect) {
return p.x >= rect.topLeft.x && p.x <= rect.bottomRight.x &&
p.y >= rect.topLeft.y && p.y <= rect.bottomRight.y;
}
function main() {
const rect = new Rectangle(new Point(0.0, 0.0), new Point(8.0, 8.0));
const p = new Point(4.0, 5.0);
if (isPointInsideRectangle(p, rect)) {
console.log("The point is inside the rectangle.");
} else {
console.log("The point is outside the rectangle.");
}
}
main();
/*
run:
The point is inside the rectangle.
*/