please help me find the bug !!!
in
Programming Questions
•
2 years ago
im trying to use radiobuttons in my project but im having this weird error saying " constructor sketch (int ,int,---------) refers to the missing type radio.
radioButton[] button = new radioButton[2];
void setup()
{
size(300,300);
smooth();
button[0] = new radioButton(33,50,30,color(255),color(0),0,button);
button[1] = new radioButton(66,50,30,color(255),color(0),1,button);
}
{
size(300,300);
smooth();
button[0] = new radioButton(33,50,30,color(255),color(0),0,button);
button[1] = new radioButton(66,50,30,color(255),color(0),1,button);
}
void draw()
{
background (204);
button[0].display();
button[1].display();
}
{
background (204);
button[0].display();
button[1].display();
}
void mousePressed()
{
button[0].press(mouseX,mouseY);
button[1].press(mouseX,mouseY);
}
{
button[0].press(mouseX,mouseY);
button[1].press(mouseX,mouseY);
}
class radioButton
{
int x,y; // x and y coordinates of the rect
int size ; // dimension of outer circle
int dotsize; // dimension of inner circle
int me; // ID number for this radio object
Radio[] others; // array of all others radio objects
boolean checked = false; // true when the button is selected
color basecolor,dotcolor;
radioButton( int xp,int yp,int s,color b,color d,int m,radio[] o)
{
x = xp;
y = yp;
size = s;
basecolor = b;
dotcolor = d;
dotsize = size - size/3;
others = o;
me = m;
}
// updates the boolean value press, returns true or false
boolean press(float mx,float my)
{
if (dist(x,y,mx,my) < size/2)
{
checked = true;
for (int i = 0;i < others.length;i++)
{
if (i != me)
{
others[i].checked = false;
}
}
return true;
}
else
{
return false;
}
}
// draws element to the display window
void display()
{
noStroke();
fill(0);
ellipse(x,y,size,size);
if (checked = true)
{
fill(dotsize);
ellipse(x,y,dotsize,dotsize);
}
}
}
{
if (dist(x,y,mx,my) < size/2)
{
checked = true;
for (int i = 0;i < others.length;i++)
{
if (i != me)
{
others[i].checked = false;
}
}
return true;
}
else
{
return false;
}
}
// draws element to the display window
void display()
{
noStroke();
fill(0);
ellipse(x,y,size,size);
if (checked = true)
{
fill(dotsize);
ellipse(x,y,dotsize,dotsize);
}
}
}
1