关于接口的问题,请各位高手帮我看一下这个程序那里出错了,谢谢
import java.awt.*;interface rect {
double area();
double getWidth();
double getHeight();
double getLocation();
}
import java.awt.*;
class Rectangle1 implements rect {
Point p = new Point();
double width,height;
int x,y;
public Rectangle1 (double w,double h,int i1,int i2) {
width = w;
height = h;
x = i1;
y = i2;
}
public double area() {
return width * height;
}
public double getWidth() {
return width;
}
public double getHeight() {
return height;
}
public Point getLocation() {
p.x = x;
p.y = y;
return p;
}
}
public class Rect {
public static void main (String [] args) {
Rectangle1 rc = new Rectangle1(2.3,8.0,1,2);
System.out.println(rc.area());
System.out.println(rc.getWidth());
System.out.println(rc.getHeight());
System.out.println((rc.getLocation()).x + (rc.getLocation()).y);
}
}