package main
import (
"fmt"
)
type Point struct {
x, y float64
}
type Rectangle struct {
topLeft, bottomRight Point
}
func isPointInsideRectangle(p Point, rect Rectangle) bool {
return p.x >= rect.topLeft.x && p.x <= rect.bottomRight.x &&
p.y >= rect.topLeft.y && p.y <= rect.bottomRight.y
}
func main() {
rect := Rectangle{
topLeft: Point{0.0, 0.0},
bottomRight: Point{7.0, 7.0},
}
p := Point{3.0, 2.0}
if isPointInsideRectangle(p, rect) {
fmt.Println("The point is inside the rectangle.")
} else {
fmt.Println("The point is outside the rectangle.")
}
}
/*
run:
The point is inside the rectangle.
*/