Я пытаюсь выполнить следующую программу. Я удалил последнюю часть MyRectangle2D
, чтобы немного сократить ее. Когда я пытаюсь скомпилировать, я получаю 2 ошибки, я просто не могу пробиться!Невозможно скомпилировать, класс не объявлен Java
TestExample.java:17: class GeometricObject2 is public, should be declared in a file named GeometricObject2.java
public abstract class GeometricObject2 {
TestExample.java:11: cannot find symbol
symbol : constructor MyRectangle2D(double,double,double,double)
location: class MyRectangle2D
GeometricObject2 rectangle1 = new MyRectangle2D(1.0, 2.0, 3.0, 4.0);
2 errors
помощь очень ценится!
import java.util.*;
public class TestExample
{
public static void main(String[] args)
{
GeometricObject2 rectangle1 = new MyRectangle2D(1.0, 2.0, 3.0, 4.0);
System.out.println(rectangle1.getArea());
}
}
public abstract class GeometricObject2 {
private String color = "white";
private boolean filled;
protected GeometricObject2() {
}
protected GeometricObject2(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public boolean isFilled() {
return filled;
}
public void setFilled(boolean filled) {
this.filled = filled;
}
public abstract double getArea();
public abstract double getPerimeter();
}
class MyRectangle2D extends GeometricObject2 {
}
Вы даже не прочитали сообщение об ошибке ... –