Class Position


public class Position extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Position(int x, int y)
    Constructor to initialize position by x and y instance variables.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Method to compare two objects of Position class.
    findNeighbours(double radius)
    The method for getting neighbours to a node in a network.
    int
    The method for retrieving the x-coordinate value.
    int
    The method for retrieving the y-coordinate value.
    int
    Method to return hash value for position.
    Returns position as a string in the format (x, y)

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Position

      public Position(int x, int y)
      Constructor to initialize position by x and y instance variables.
      Parameters:
      x - the x-coordinate value.
      y - the y-coordinate value.
  • Method Details

    • getX

      public int getX()
      The method for retrieving the x-coordinate value.
      Returns:
      the x-coordinate value.
    • getY

      public int getY()
      The method for retrieving the y-coordinate value.
      Returns:
      the y-coordinate value.
    • findNeighbours

      public ArrayList<Position> findNeighbours(double radius)
      The method for getting neighbours to a node in a network.
      Parameters:
      radius - the radius where to search for neighbours
      Returns:
      the arraylist of positions of these nodes.
    • equals

      public boolean equals(Object o)
      Method to compare two objects of Position class.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to be compared.
      Returns:
      true if the objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Method to return hash value for position.
      Overrides:
      hashCode in class Object
      Returns:
      calculated hashcode value for Position.
    • toString

      public String toString()
      Returns position as a string in the format (x, y)
      Overrides:
      toString in class Object
      Returns:
      position as a string