Class Node


public class Node extends Object
  • Constructor Details

    • Node

      public Node(Position position)
      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

      public Position getPosition()
      Returns the position of the node.
      Returns:
      the position of the node.
    • setNeighbours

      public void setNeighbours(Node node)
      Adds a node neighbour to the neighbour list.
      Parameters:
      node - the neighbour to add to the list.
    • getNeighbours

      public ArrayList getNeighbours()
      Returns the list of neighbours as an ArrayList.
      Returns:
      the list of neighbours.
    • addEvent

      public void addEvent(String eventId, Node nextNode, int distance)
      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

      public Agent detectEvent(String eventId, int agentProbability)
      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

      public HashMap<String,RoutingEntry> 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

      public Agent generateAgent(int probability, int maxSteps)
      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

      public String toString()
      Returns the node as a string. This contains the node position, its neighbours and its status.
      Overrides:
      toString in class Object
      Returns:
      the node as a string.