I'm new to Processing and working on the Tutorials. After watching the the tutorials until the "OOP" Part, i tried to play with the things i've learned.
The Code is about creating two Cars with one Constructor. You may see that it is quite the same code as in the tutorial:
Car myCar1;
Car myCar2;
Car myCar3;
int[] numbers = { 90, 100, 30 };
void setup() {
size(200,200);
smooth();
frameRate(100);
// Parameters go inside the parentheses when the object is constructed.
myCar1 = new Car(color(255,0,0),0,numbers[0],2);
myCar2 = new Car(color(0,0,255),0,numbers[1],PI/2);
myCar3 = new Car(color(0,255,255),0,numbers[2],PI/2/PI*2);
So now are 3 Cars, but only one will be drawn on line 17 to 19.
I know how to solve the problem. I've just to copy this 3 lines and rename it to myCar2 && myCar3.
But my question is,... can i actually count it? On line 4 I created an array with 3 integer.
and on line 15 I created an counter. I thougt something like
String ncount = "myCar" + go_on;
This works fine while using "println (ncount);"
But it will not work for line 17-19:
ncount.colour();
ncount.drive();
ncount.display();
I know the reason. Beause ncount is an String, but I've no Idea how the solution looks like. Could you please help me.