0
선생님은 내가 만든 두 개의 사각형 사이의 교차점을 찾길 원합니다. 왜 이것이 실행되지 않는지 알아 내도록 도와주세요. 내가 말한 오류는 가변 하단을 찾을 수 없습니다.사각형 자바 교차점
public class Rectangle {
private int left, bottem, width, height;
public Rectangle (int l, int b, int w, int h) {
left = l;
bottem = b;
width = w;
height = h;
}
public int getX() {
return left;
}
public int getY() {
return bottem;
}
public int getW() {
return width;
}
public int getH() {
return height;
}
public int getArea() {
int area;
area = (width * height);
return area;
}
public int getPerimeter() {
int perimeter;
perimeter = (width + height) * 2;
return perimeter;
}
public int getIntersection (Rectangle one, Rectangle two) {
int intxValue;
int intyValue;
int intxValue2;
int intyValue2;
int area;
if (one.left + one.width > two.left && one.bottom + one.height > two.bottom) {
intxValue = two.left;
intyValue = two.bottom;
intxValue2 = one.left + one.width - intxValue;
intyValue2 = one.bottom + one.height - intyValue;
area = intxValue2*intyValue2;
return area;
} else if (one.left+one.width < two.left && one.bottom+one.height < two.bottom) {
intxValue = one.left;
intyValue = one.bottom;
intxValue2 = two.left + two.width - intxValue;
intyValue2 = two. bottom + two.height - intyValue;
area = intxValue2*intyValue2;
return area;
} else return area;
}
'bottem'은'bottom'과 같은 것이 아닙니다. –
무료로 당신을 도울 것을 요청하는 사람들에게 예의를 보이고 코드를 읽기 쉽게하십시오. – djechlin
오, 쓰레기 철자 오류 : P –