Class Node
java.lang.Object
Node
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds event to routing table.detectEvent(String eventId, int agentProbability) Detects the event and returns an agent based on a probability out of 100.generateAgent(int probability, int maxSteps) Returns a new agent based on probability out of 100.Returns the routing table of events.Returns the list of neighbours as an ArrayList.Returns the position of the node.booleanReturns the availability status.voidsetNeighbours(Node node) Adds a node neighbour to the neighbour list.voidsetStatus(boolean status) Sets the availability status.toString()Returns the node as a string.
-
Constructor Details
-
Node
Constructs and initializes the node with a position, list of neighbours, tha availability set to true and a routing table.- Parameters:
position- the position of the node.
-
-
Method Details
-
getPosition
Returns the position of the node.- Returns:
- the position of the node.
-
setNeighbours
Adds a node neighbour to the neighbour list.- Parameters:
node- the neighbour to add to the list.
-
getNeighbours
Returns the list of neighbours as an ArrayList.- Returns:
- the list of neighbours.
-
addEvent
Adds event to routing table.- Parameters:
eventId- the event id as a string.nextNode- the node next to go to get to the node that detected the event.distance- the number of steps to the node that detected the event.
-
detectEvent
Detects the event and returns an agent based on a probability out of 100. The event is added to the routing table with distance 0.- Parameters:
eventId- the event id as a string.- Returns:
- an agent if one is created, otherwise null.
-
getEvents
Returns the routing table of events.- Returns:
- the routing table.
-
setStatus
public void setStatus(boolean status) Sets the availability status.- Parameters:
status- the status true/false.
-
getStatus
public boolean getStatus()Returns the availability status.- Returns:
- the availability status.
-
generateAgent
Returns a new agent based on probability out of 100.- Parameters:
probability- the probability out of 100.maxSteps- the maximum number of steps the agent will take.- Returns:
- an agent if one was created, otherwise null.
-
toString
Returns the node as a string. This contains the node position, its neighbours and its status.
-