HI,
This is a program that compiles but doesn't run. I get the error that the constructor rectangle[i]= new CompareRectangle is a malformed expression. Could someone help with this?
THANKS!!! Mary Ellen

CompareRectangle.java--This program will create a class named CompareRectangle
that will extend Rectangle and implement CompareObject. Implementation of the compareTo() method that will compare the rectangles on their areas will occur. A
test class will be written to sort a list of CompareRectangle objects.*/
package Chapter7;
public class CompareRectangle extends Rectangle implements CompareObject
{
public static void main(
String[] args)
{
//Create rectangles
CompareRectangle[] rectangle = new CompareRectangle[10];
for (int i = 0; i<rectangle.length; i++);>
rectangle[i] = new CompareRectangle(100*Math.random(),5.0, 8.0, "white");
//Construct a CompareRectangle with specified area and color
public CompareRectangle(double width, double height, double w, String c)
{
super(w, c);
}
//Implement compare method defined in CompareObject
public int compareTo(CompareObject otherObject)
{
Rectangle rectangle = (Rectangle)otherObject;
if(findArea() < rectangle.findArea())
return LESS;
else if (findArea() == rectangle.findArea())
return EQUAL;
else return GREATER;
}
public String toString()
{
return "The rectangle area is: " + findArea();
}
}
}