Class Command
java.lang.Object
za.co.wethinkcode.robots.server.commands.Command
- Direct Known Subclasses:
ExternalCommand
Every command follows this same pattern:
- It receives a robot name and arguments
- It runs against the world
- It returns a result string
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract com.google.gson.JsonObjectModern a modern OO implementation of the execute methodabstract StringexecuteToString(World world) Each command must implement this method It does the work and returns a resultprotected RobotHelper: look up the robot in the world Returns null if the robot doesn't existGet the name of the robot that this command is being executed on
-
Constructor Details
-
Command
Required command constructor- Parameters:
robotName- the name of the robot the command is being executed on
-
Command
public Command(com.google.gson.JsonObject json) throws ClassCastException, UnsupportedOperationException, IllegalStateException Overload command constructor- Parameters:
json- the Json version of the input- Throws:
ClassCastExceptionUnsupportedOperationExceptionIllegalStateException
-
-
Method Details
-
getRobotName
Get the name of the robot that this command is being executed on- Returns:
- the name of robot
-
executeToString
Each command must implement this method It does the work and returns a result -
execute
Modern a modern OO implementation of the execute method -
findRobot
Helper: look up the robot in the world Returns null if the robot doesn't exist
-