I want to have 2 static functions called turnOn() and turnOff().
Say objectA calls turnOn(), then objectB calls turnOn(). Then objectA calls turnOff(), it should not turn off because objectB turned it on as well.
Also say objectA calls turnOn(), then objectB calls turnOn(). Then objectB calls turnOff(), it should not turn off because objectA hasn't turned it off yet.
Finally, if objectA and objectB turn it on, it turns off when they both turn it off.
I was thinking keeping track of how many turnOn and TurnOff's are called and make sure it matches, but thats not truly accurate because objectA can call turnOff() twice.
So whats the best sort of way to handle this?
Thanks!