You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
805 B

package parser.ast;
public class AccumulationFunction {
public AccumulationFunction(AccumulationType type) {
this.type = type;
}
public AccumulationType type;
private Object rewardIndex = null;
public Object getRewardIndex() {
return rewardIndex;
}
public void setRewardIndex(Object index) {
rewardIndex = index;
}
public String toString() {
switch(this.type) {
case ACC_REWARD:
return "reward" + indexString();
case ACC_STEPS:
return "steps";
case ACC_TIME:
return "time";
default:
throw new RuntimeException("Unknown accumulation function");
}
}
private String indexString() {
if (rewardIndex == null) return "";
if (rewardIndex instanceof String) return "{\"" + rewardIndex + "\"}";
else return "{" + rewardIndex.toString() + "}";
}
}