Here is the source code of the robot
public class AdvReplacerRobot extends WithWorkersRobot {
public AdvReplacerRobot(){
super();
/* One should add his/hers workers here. */
addRobotWorker(new LengthWorker() );
addRobotWorker(new WaveInformationWorker() );
}
@Override
public String getRobotIdentifier() {
// TODO return a string or this will not compile
// for example :
return "rplc";
/* an identifier is for identifying an advanced robot in a
conversation, ba*ecause there can be more than one
TIP: make it short !
*/
}
@Override
protected String getRobotSelfIntroduction() {
/* TODO Return the text the robot will blip when it is added to a
conversation */
// example :
return super.getRobotSelfIntroduction() + " Mr Waver, I am a
replacer tests robot.";
// will return Bonjour! Hello ! Namaste ! Salam ! buna ziua ! Mr
Waver, I am an advanced robot, what about you ?
}
@Override
protected String getDisplayName() {
// TODO
// EXAMPLES return "MYROBOTWithWorkers (" + super.getDisplayName()
+")";
//
return "AdvReplacer";
}
and now the code of the LengthWorker
public class LengthWorker implements RobotWorker {
@Override
public String getInstruction() {
return "len";
}
@Override
public String getDescription() {
return "Displays the length of the blip ";
}
@Override
public boolean doWork(EventMessageBundle bun, Blip bli, Event
eve,String params)
{
return true;
}
@Override
public boolean areCommandsToClean() {
return false;
}
@Override
public String getReplacingValue(Command c, EventMessageBundle bundle,
Blip blip, Event event) {
return "" + (BlipUtils.getEventBlipText(event).length() - ( 3+
c.getAcronym().length() + c.getInstruction().length())) ;