import java.util.ArrayList;
public class circleTester {
public static void showCenter(Circle2 circle) {
System.out.println(circle.getName() + "'s " + circle.getCenter());
}
public static void main (String []args) {
ArrayList<Circle2> circles = new ArrayList<Circle2>();
circles.add(new Circle2(3, 5, 4));
circles.add(new Circle2(4, 2, 5));
circles.add(new Cylinder2(5, 2, 3, 5));
circles.add(new Cylinder2(3, 4, 7, 6));
circles.add(new Oval2(6, 5, 7, 3));
circles.add(new Oval2(4, 2, 3, 1));
circles.add(new OvalCylinder2(2, 3, 4, 5, 6));
circles.add(new OvalCylinder2(3, 3, 5, 4, 7));
for (Circle2 i : circles) {
showCenter(circles(i));
}
}
}
I have four separate classes: Circle2, Cylinder2, Oval2, and OvalCylinder2. They're all derived from Circle2, and OvalCylinder2. I'm trying to put them into an array list, and then iterate through the array list and run each instance through the showCenter function, which will call two getter (getName and getCenter) to tell you the class' name (Circle, Cylinder, Oval, and ovalCylinder), and where it's center is (x, y). However, in my for loop, I get an error:
"The method circles(Circle2) is undefined for the type circleTester" How do I fix this?