카테고리 없음
[자바] 점이 사각형의 경계 내에 있으면 true를 반환합니다.
필살기쓰세요
2021. 2. 17. 19:45
public static boolean contains(Rectangle r, Point p)
{
// TODO - you need to implement this. May want to use isInBetween
return p.x >= r.x && p.y >= r.y && p.x <= r.x + r.width && p.y < =r.y + r.height;
}
또는 주석에서 언급했듯이 IsBetween을 사용할 수 있습니다.
public static boolean contains(Rectangle r, Point p)
{
return Assignment6.isBetween(p.x,r.x,r.x+r.width) && Assignment6.isBetween(p.y,r.y,r.y+r.height);
}
출처
https://stackoverflow.com/questions/39940063