I'm trying to make 15 different instances of a polygon with each one having a different radius, starting with 225 and each one being 15 pixels shorter than the other, The second and third fields are the coordinates of where the objects center will be places. I know the [i] doesn't work, and I have read that I should use an array, but i am having trouble implementing it to my code:
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int i;
int number = 15;
int radiussize = 225;
for(i=0;i<=number;i++){
Shape object[i]= new Shape(radiussize-(i*15),250,300);
object[i].draw(g2);
}
}
I want the result to be 15 objects named:
object0, object1, object2...object15.