posted 10 years ago
hello I have to create a method with the following header :
public static <E extends Comparable<E> > void sort ( ArrayList<E> list , int left, int right)
i also had to create a swap cells method and position of max integer method. and also had to read the preserved data file in with a scanner. I implemented the comparable interface I am having difficulty sorting my list by the area. It has to be in desscending order. Can someone please help me with my sorting method?
Geometric Object class: since it has comparator also am interested if i need to change this?
CODE:
Driver:
output:
Position of max area is...4
[>>> Circleblue
GeometricObject [color=blue, filled=true, dateCreated=Tue Mar 18 17:33:27 EDT 2014]
>>>Radius2.0Area: 12.566370614359172, >>> Circleblue
GeometricObject [color=blue, filled=true, dateCreated=Tue Mar 18 17:33:27 EDT 2014]
>>>Radius10.0Area: 314.1592653589793,
>>>Rectangleyellow
GeometricObject [color=yellow, filled=true, dateCreated=Tue Mar 18 17:33:27 EDT 2014]
>>>Height:6.0Width:10.0Area:60.0,
>>>Rectanglegreen
GeometricObject [color=green, filled=true, dateCreated=Tue Mar 18 17:33:27 EDT 2014]
>>>Height:11.0Width:5.0Area:55.0, >>> Circlered
GeometricObject [color=red, filled=false, dateCreated=Tue Mar 18 17:33:27 EDT 2014]
>>>Radius4.0Area: 50.26548245743669]