Interface Command

All Known Implementing Classes:
AbstractCommand, AbstractRandomDecisionCommand, CmdAttack, CmdBack, CmdClear, CmdDeleteGame, CmdDodge, CmdDrop, CmdEquip, CmdFight, CmdHelp, CmdListGames, CmdLoadGame, CmdLook, CmdMove, CmdNewGame, CmdPick, CmdRun, CmdSaveGame, CmdShow, CmdUse, CmdWai, DummyCmd

public interface Command
Interface for command.
  • Method Details

    • getArgs

      List<String> getArgs()
      Gets a copy of the argument list.
      Returns:
      A copy of the argument list.
    • getPossibleArgs

      List<String> getPossibleArgs() throws GameStorageException
      Get a list of all the available argument for this command (necessary for command prediction)
      Returns:
      ArrayList with all the possible arguments
      Throws:
      GameStorageException - If errors occur while fetching game data from the storage.
    • setArgs

      void setArgs(List<String> args)
      Sets command arguments.
      Parameters:
      args - Arguments.
    • getContext

      ApplicationContext getContext()
      Gets command context.
      Returns:
      Application context.
    • getWriter

      Writer getWriter()
      Gets current stdout writer.
      Returns:
      Stdout writer.
    • getInputStream

      InputStream getInputStream()
      Returns command stdin.
      Returns:
      Input stream.
    • setContext

      void setContext(ApplicationContext context)
      Sets command context.
      Parameters:
      context - Application context.
    • setWriter

      void setWriter(Writer out)
      Sets stdout writer for command.
      Parameters:
      out - Output writer.
    • setInputStream

      void setInputStream(InputStream inputStream)
      Sets command stdin.
      Parameters:
      inputStream - Input stream.
    • execute

      void execute() throws InterruptedException
      Executes the command.
      Throws:
      InterruptedException - Thrown if the command is interrupted (e.g. when kill is well implemented).
    • kill

      void kill()
      Requests command termination. This ONLY asks the command to terminate, but termination depends on the correct implementation of the command. If the command was executing then it will throw InterruptedException.