요 문제 풀고 있는데요
public class ch4_2 {
public class Rectangle{
public int x1,x2,y1,y2;
public Rectangle(){}
public Rectangle(int x1,int y1, int x2,int y2){
this.x1=x1;
this.x2=x2;
this.y1=y1;
this.y2=y2;
}
void set(int x1, int y1, int x2, int y2){
this.x1=x1;
this.x2=x2;
this.y1=y1;
this.y2=y2;
}
void show(){
int s ;
s = (x1-x2)*(y1-y2);
if(s<0)
s*=-1;
System.out.println("사각형의 넓이 " + s);
System.out.println("좌표 x1 >> " + x1 + "좌표 y1 >> "+ y1 +"좌표 x1 >> " + x2 + "좌표 y2 >> "+ y2);
}
int square(){
int s ;
s = (x1-x2)*(y1-y2);
if(s<0)
s*=-1;
return s;
}
// boolean equals(Rectangle r){
// if(r == )
//}
}
public static void main(String[] args) {
Rectangle r = new Rectangle(); <- 여기가 no enclosing instance 에러가 나요
Rectangle s = new Rectangle(1,1,2,3);
r.show();
s.show();
System.out.println(s.square());
r.set(-2,2,-1,4);
r.show();
System.out.println(r.square());
//if(r.equals(s))
//System.out.println("두 사각형은 같습니다");
}
}
그리고 boolean을 어떻게 짜야 될지 모르겠어요
자바 어려워요
도와주세요