Hi!
I am not that good in java and as a homework we had to write to classes: a partial abstract class Koerper and it's subclass Kugel but when I try to compile them the compiler always tells me this:
Kugel.java:9: Kugel is not abstract and does not override abstract method compareTo(java.lang.Object) in java.lang.Comparable
public class Kugel extends Koerper
I hope someone can help I'm just not able to figure it out... maybe it's nothing big, but i don't get it :)
The code of both classes is as follows:
abstract class Koerper implements Comparable
{
public double volumen;
public double oberflaeche;
public double PI=3.14159265;
public abstract void volumen();
public abstract void oberflaeche();
public void setVolumen(double v)
{
volumen=v;
}
public void setOberflaeche(double o)
{
oberflaeche=o;
}
public double getVolumen()
{
return volumen;
}
public double getOberflaeche()
{
return oberflaeche;
}
public double compareTo(Koerper object)
{
double temp=0;
if(object.volumen>volumen)
temp=object.volumen;
if(object.volumen<volumen)
temp=volumen;
if(object.volumen==volumen)
temp=volumen;
return temp;
}
public class Kugel extends Koerper
{
public double r;
public Kugel(double radius){
r=radius;
volumen();
oberflaeche();
}
public void volumen()
{
double V;
V=(4/3)*Math.PI*r*r*r;
setVolumen(V);
}
public void oberflaeche()
{
double O;
O=4*Math.PI*r*r;
setOberflaeche(O);
}
}
...