I want to refer to a class rather than an object, so I don’t need a seperate if statement for each object, does anybody know how to do this?
maybe you could give us some example code. not sure what you mean with the ‘if statement’ part.
if you have many instances of a class, you may give each one a very unique name - then you would have to remember all those names.
or - usually - you would create an array of the objects and address them through a for-loop.
that way each instance would have its own random number anyway…
myClass [] xy;
void setup() {
xy = new myClass[100];
for (int i=0; i<100; i++) {
xy[i] = new myClass();
}
}
//-----------------------
class myClass {
float r;
//-----------------------
myClass () {
findRandom ();
}
//-----------------------
void findRandom () {
r = random (0,789);
print (r);
}
}