public class AXMachineCode {
private Hashtable<String,Integer> dic = new Hashtable<>();
public AXMachineCode addKeyValuePair(String key, int value){
dic.put(key,value);
return this;
}
public int getMachineCodeFor(String key){
return dic.getOrDefault(key,-1);
}
}
public class AXInputWaiter {
// wait for any input
private TrgTolerance trgTolerance;
public AXInputWaiter(int tolerance) {
this.trgTolerance = new TrgTolerance(tolerance);
trgTolerance.reset();
}
public void reset(){
trgTolerance.reset();
}
public Boolean wait(String s1){
// return true till any input detected or till x times of no input detection
if (!s1.isEmpty()){
return false;
}
return trgTolerance.trigger();
}
public void setWait(int timesToWait){
trgTolerance.setMaxrepeats(timesToWait);
}
}
class AXMachineCode:
def __init__(self):
self.dic: dict[str, int] = {}
def addKeyValuePair(self, key: str, value: int) -> AXMachineCode:
self.dic[key] = value
return self
def getMachineCodeFor(self, key: str) -> int:
if not key in self.dic:
return -1
return self.dic[key]