Hi guys, I'm new here.
I'm trying to make an abstract class Point with concrete classes of Point1D, Point2D, Point3D, with a general method in Point to compute the distance between current point to origin despite its type of Point1D, 2D or 3D. I came up with this:
public abstract class Point {
private double distance;
protected Point() {
distance = 0.0;
}
public abstract void computeDistance();
}
public class Point1D extends Point {
void computeDistance(double dist) {
System.out.println("Distance is " +dist);
}
}
When I tried to compile Point1D, I get this error message: Point1D is not abstract and does not override abstract method computeDistance() in Point
When I tried to make Point1D an abstract class, it compiles just fine. But that would defeat the whole purpose of Point being an abstract class for the concrete classes Point1D-3D.
So I guess my question is, how do I make Point1D a concrete class without the compiler complaining?
Thanks for your time! Any help is appreciated