Let's say I have a program (using the behavior API) that works like:
- Code: Select all
Behavior b1 = new State1();
Behavior b2 = new State2();
Behavior b3 = new State3();
Behavior [] choices = {b1,b2,b3};
Arbitrator arb = new Arbitrator(choices);
arb.start;
where the 3 states basically work as such; behavior 1 and 2 depend on a boolean value to determine which behavior will occur, while behavior 3 will kick in once a counter--let's say the number of times behavior 2 has occurred--gets to a preset value.
The question is, then, how would I make this happen? Clearly, the counter value for behavior 3 would be passed to takeControl() in behavior 3, but the question I have is *how* do I actually make a global variable (lets call it counter) that can be iterated in the class file for behavior 2, and looked at in the class file for behavior 3?
Sorry if this is a really dumb question, my knowledge of JAVA programming is still quite limited...
Cheers!
