Class Request


public class Request extends Message
  • Constructor Details

    • Request

      public Request(int maxSteps, Node startNode, Event event)
      Constructs and initializes a request.
      Parameters:
      maxSteps - the maximum number of steps the agent message can take.
  • Method Details

    • move

      protected void move()
      Method that moves a request, if detect node is found it responds. Moves until detect node is found or maximum steps has been reached.
      Specified by:
      move in class Message
    • rememberPositions

      protected void rememberPositions()
      Method that removes the current node from stack of previous moves and adds it to array list of previous positions.
      Specified by:
      rememberPositions in class Message
    • getPossibleMoves

      protected ArrayList<Node> getPossibleMoves()
      Method that gets the possible moves for an agent.
      Specified by:
      getPossibleMoves in class Message
      Returns:
      arraylist of the possible moves
    • setCurrentNode

      protected void setCurrentNode(Node node)
      Method that sets a node to current node
      Specified by:
      setCurrentNode in class Message
      Parameters:
      node - the node to set to current node
    • respond

      public void respond()
      Method that goes back to the start node and prints the information of the event
    • currentPositionOfRequest

      public Position currentPositionOfRequest()
      Method that returns the current position of the request
      Returns:
      the position of the node
    • getNumSteps

      public int getNumSteps()
      Method that return the number of steps taken by the request
      Returns:
      number of steps
    • getMaxSteps

      public int getMaxSteps()
      Method that returns the maximum steps for the request
      Returns:
      maximum steps
    • getStartNode

      public Node getStartNode()
      Returns start node of the request
      Returns:
      start node
    • getEvent

      public Event getEvent()
      Returns event of the request
      Returns:
      event
    • requestHasResponded

      public boolean requestHasResponded()
      Method that returns if a request has responded or not
      Returns:
      the status of which the request has responded or not
    • hasFoundDetectNode

      public boolean hasFoundDetectNode()
      Returns whether request has found detection node or not
      Returns:
      true if it has found position of occurrence of event, otherwise false
    • getPreviousMoves

      protected Stack<Node> getPreviousMoves()
      Method that gets the previous moves of the request.
      Returns:
      the stack of previous moves
    • getPreviousPositions

      protected ArrayList<Node> getPreviousPositions()
      Method that gets the previous positions of the request.
      Returns:
      the list of previous positions
    • getCurrentNode

      protected Node getCurrentNode()
      Method that gets the current node of the request.
      Returns:
      the current node
    • toString

      public String toString()
      Returns request as a string containing its position and number of steps it has taken
      Overrides:
      toString in class Object
      Returns:
      request as a string