Add an interface, SizeComparable, that includes only the boolean isBiggerThan( Shape other) method. In your ShapeSet class, provide a method void sort(), that sorts the shapes of the shape set by class Shape implementing the SizeComparable interface.
This is the problem I wrote codes but it gives run-time error.Could you help me?

public abstract class Shape implements SizeComparable {
    Shape a;

    public abstract double getArea();

    public boolean isBiggerThan(Shape other){
        if(other.getArea()>a.getArea())
            return true;
        else
            return false;   
    }
}
--------------------------------------------------------------------------------------

public interface SizeComparable {
    public boolean isBiggerThan(Shape other);
}
-------------------------------------------------------------------------------------

public class ShapeSet {
    //properties
    Shape[] shapeList;
    int number;
//constructor
    public ShapeSet(){
        shapeList=new Shape[19];
        number=0;
    }
............
.........
public void sort()
   {
       int in, out;

       for(out=1; out<number; out++) // out is dividing line
         {
         Shape temp = shapeList[out];    // remove marked Shape
         in = out;          // start shifting at out

         while(in>0 &&        // until smaller one found,
            temp.isBiggerThan(shapeList[in]))
          {
          shapeList[in] = shapeList[in-1];     // shift item to the right
          --in;          // go left one position
          }
         shapeList[in]= temp;        // insert marked item
         } // end for
   } // end Sort()

}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

thnks for your help but I need help about sorting..thnks for your trying:)

I realize that it unnecessary to define shape object in shape class.I remove shape object from class and it works...
--------------------------------------------------------------------------------------
public abstract class Shape implements SizeComparable {
public abstract double getArea();

public boolean isBiggerThan(Shape other){
if(other.getArea()>this.getArea())
return true;
else
return false;
}
}

This question has already been answered. Start a new discussion instead.