I want to go through the colors in my given Color [] colors; then once it goes through all 5 colors in the array, to start all over
Best solution I can think of is using a switch case:
//define Color[] colors = {color1, color2, color3, color4, color5};
int i=0;
while(true)
{
switch (i)
{
case 1: object.setColor(color1);
break;
case 2: object.setColor(color2);
break;
case 3: object.setColor(color3);
break;
case 4: object.setColor(color4);
break;
case 5: object.setColor(color5);
break;
default: object.setColor(color1); //when all else goes wrong
break;
}
if( i == 5 )
i = 1;
else
i++;
}