Java:
public class AXConvince {
private AXContextCmd req;
private Responder reset = new Responder( "reset");
private int min = 3; // minimum requests till agreement
private int max = 6;
private DrawRnd rnd = new DrawRnd();
private int counter = 0;
private Boolean mode = false;
public AXConvince(AXContextCmd req) {
this.req = req;
}
public int engage(String ear){
if(reset.responsesContainsStr(ear)){
counter = 0;
mode = false;
min += rnd.getSimpleRNDNum(max);
return 3;
}
if(req.engageCommand(ear)) {
counter++;
if(counter < min){return 1;}
else{mode = true;return 2;} // convinced
}
return 0;
}
public boolean isConvinced(){return mode;}
}