I’ve created an LED class that has worked well for me upto this point. Now, I have an array of leds and I need to know the state (weather it’s on or off) of a particular led. To do that I’ve added getState() to the class but the method is not correct. Say, for instance, that I have an array of leds and I want to know the state of led[3]. I can, of course, set the state with led[3].setState(true) but how to I get the state?
class Led
{
boolean state;
color col, onColour, offColour;
int ledSize, xpos, ypos;
Led(int x, int y)
{
xpos = x;
ypos = y;
}
void setState(boolean s)
{
state = s;
}
boolean getState(Led) // this is not correct.
{
return state;
}