先生は、私が作成した 2 つの長方形の交点を見つけてほしいと言っています。これが実行されない理由を理解するのを手伝ってください。変数の底が見つからないというエラーが表示されます。
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;
}