this method is inside the class! (Which is debatable!)
you need
Class_B dummy= new Class_B(BX+100, BY+100, 30, 35, 125, “5”); //
Class_B refClass_B = dummy.getClass_B(i);
But there are other errors
but there are other errors; missing function draw(), one { too much…
Initialize() doesn’t exist
the elements are not added to the ArrayList…
Here is a version that works
// INITIALIZE SHEET : see below: Initialize()
//////////////////////////////////////////////////////////////////////////
ArrayList<Class_B> class_b_elements = new ArrayList<Class_B>();
//////////////////////////////////////////////////////////////////////////
// CLASS B SHEET :
//////////////////////////////////////////////////////////////////////////
class Class_B {
float x;
float y;
float w;
float h;
int couleur;
String Blabel;
int tStatus=1; // specifies current status (0=off/not visible, 1=on/visible)
int hStatus=0; // specifies if current is highlighted (1) or normal (0)
//////////////////////////////////////////////////////////////////////////
//constr
Class_B(float x, float y, float w, float h, int couleur, String Blabel) { // rectangle
this.x=x;
this.y=y;
this.w=w;
this.h=h;
this.couleur=couleur;
this.Blabel=Blabel;
}//constr
String toString() {
return
Blabel
+": "
+str(x)
+","
+str(y)
+" etc. ....";
}//func
//////////////////////////////////////////////////////////////////////////
} // Class_B definition
//////////////////////////////////////////////////////////////////////////
// MAIN SHEET :
//////////////////////////////////////////////////////////////////////////
final int SCREEN_WIDTH = 800;
final int SCREEN_HEIGHT = 500;
//////////////////////////////////////////////////////////////////////////
void settings() {
size(SCREEN_WIDTH, SCREEN_HEIGHT);
}
//////////////////////////////////////////////////////////////////////////
void setup() {
background(0);
Initialize();
for (int i = 0; i<5; i = i+1) {
Class_B refClass_B = getClass_B(i);
println ("refClass_B:", refClass_B.toString());
}
}
//////////////////////////////////////////////////////////////////////////
void draw() {
//
background(0);
for (int i = 0; i<5; i = i+1) {
Class_B refClass_B = getClass_B(i);
text ("refClass_B: " + refClass_B.toString(),
30, i*30+44);
}
}
//////////////////////////////////////////////////////////////////////////
// CREATE - Class D
void Initialize() {
float BX = 100;
float BY = 100;
Class_B class_b_elementA1 = new Class_B(BX+10, BY+10, 10, 15, 25, "1"); // (x, y, w, h, couleur, Id)
Class_B class_b_elementA2 = new Class_B(BX+25, BY+25, 15, 20, 50, "2"); //
Class_B class_b_elementA3 = new Class_B(BX+45, BY+45, 20, 25, 75, "3"); //
Class_B class_b_elementA4 = new Class_B(BX+70, BY+70, 25, 30, 100, "4"); //
Class_B class_b_elementA5 = new Class_B(BX+100, BY+100, 30, 35, 125, "5"); //
class_b_elements.add(class_b_elementA1);
class_b_elements.add(class_b_elementA2);
class_b_elements.add(class_b_elementA3);
class_b_elements.add(class_b_elementA4);
class_b_elements.add(class_b_elementA5);
//
} //
Class_B getClass_B(int i) {
Class_B refClass_B = class_b_elements.get(i);
return refClass_B;
} //
//