java.lang.Object
za.co.wethinkcode.robots.server.commands.Command
Direct Known Subclasses:
ExternalCommand

public abstract class Command extends Object
Every command follows this same pattern:
  1. It receives a robot name and arguments
  2. It runs against the world
  3. It returns a result string
  • Constructor Summary

    Constructors
    Constructor
    Description
    Command(com.google.gson.JsonObject json)
    Overload command constructor
    Command(String robotName)
    Required command constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract com.google.gson.JsonObject
    execute(World world)
    Modern a modern OO implementation of the execute method
    abstract String
    Each command must implement this method It does the work and returns a result
    protected Robot
    Helper: look up the robot in the world Returns null if the robot doesn't exist
    Get the name of the robot that this command is being executed on

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getRobotName

      public String getRobotName()
      Get the name of the robot that this command is being executed on
      Returns:
      the name of robot
    • executeToString

      public abstract String executeToString(World world)
      Each command must implement this method It does the work and returns a result
    • execute

      public abstract com.google.gson.JsonObject execute(World world)
      Modern a modern OO implementation of the execute method
    • findRobot

      protected Robot findRobot(World world)
      Helper: look up the robot in the world Returns null if the robot doesn't exist