Reputation: 65
Alright so all of the methods word except the minMax method, this is a file that takes information from my CircleWithPrivateDataFields.java If you need any of the code from that you can let me know and I can reedit this file with the appropriate files.
This is my error: double cannot be converted to CircleWithPrivateDataFields
what will I have to do for this to work, I know I'm very close, but I'm not sure where to go from here.
Remember it's the minMax method that only needs work.
Thanks in advance!
public class TotalArea {
public static void main(String[] args) {
//Declare circle array
CircleWithPrivateDataFields[] circleArray;
//Create circleArray
circleArray = createCircleArray();
printCircleArray(circleArray);
minMax(circleArray);
}
public static CircleWithPrivateDataFields[] createCircleArray() {
CircleWithPrivateDataFields[] circleArray = new CircleWithPrivateDataFields[5];
for (int i=0; i < circleArray.length; i++) {
circleArray[i] = new CircleWithPrivateDataFields(Math.random() * 100);
}
//Return circle array
return circleArray;
}//end createCircleArray method
/*
takes the array of circles and determines the
smallest and largest circles in the array and prints out their information.
*/
public static void minMax(CircleWithPrivateDataFields[] circleArray) {
System.out.println();
double max;
for (int i=0; i<circleArray.length; i++) {
if(circleArray[i].getRadius() > 0) {
circleArray[i] = max;
}
}
}
//Add circle areas
public static double sum(CircleWithPrivateDataFields[] circleArray) {
//Initalize sum
double sum = 0;
//Add areas to sum
for (int i=0; i<circleArray.length; i++)
sum += circleArray[i].getArea();
return sum;
}
}
Upvotes: 1
Views: 1459
Reputation: 22903
You are adding max
(a double
) to circleArray
which is an array of CircleWithPrivateDataFields
.
You have to make sure that circleArray
is an array of double
or that the CircleWithPrivateDataFields
class extends Double
.
Upvotes: 1