Class Request
java.lang.Object
Message
Request
-
Field Summary
Fields inherited from class Message
currentNode, maxSteps, numSteps, previousMoves, previousPositions, waitingQueue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMethod that returns the current position of the requestprotected NodeMethod that gets the current node of the request.getEvent()Returns event of the requestintMethod that returns the maximum steps for the requestintMethod that return the number of steps taken by the requestMethod that gets the possible moves for an agent.Method that gets the previous moves of the request.Method that gets the previous positions of the request.Returns start node of the requestbooleanReturns whether request has found detection node or notprotected voidmove()Method that moves a request, if detect node is found it responds.protected voidMethod that removes the current node from stack of previous moves and adds it to array list of previous positions.booleanMethod that returns if a request has responded or notvoidrespond()Method that goes back to the start node and prints the information of the eventprotected voidsetCurrentNode(Node node) Method that sets a node to current nodetoString()Returns request as a string containing its position and number of steps it has taken
-
Constructor Details
-
Request
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. -
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:
rememberPositionsin classMessage
-
getPossibleMoves
Method that gets the possible moves for an agent.- Specified by:
getPossibleMovesin classMessage- Returns:
- arraylist of the possible moves
-
setCurrentNode
Method that sets a node to current node- Specified by:
setCurrentNodein classMessage- 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
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
Returns start node of the request- Returns:
- start node
-
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
Method that gets the previous moves of the request.- Returns:
- the stack of previous moves
-
getPreviousPositions
Method that gets the previous positions of the request.- Returns:
- the list of previous positions
-
getCurrentNode
Method that gets the current node of the request.- Returns:
- the current node
-
toString
Returns request as a string containing its position and number of steps it has taken
-