Class AstarStrategy.Node

java.lang.Object
com.edu.xmum.CST210.AlgorithmStrategy.AstarStrategy.Node
All Implemented Interfaces:
Comparable<AstarStrategy.Node>
Enclosing class:
AstarStrategy

public static class AstarStrategy.Node extends Object implements Comparable<AstarStrategy.Node>
Inner class representing a node in the A* algorithm.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Node(int x, int y, int g, int h)
    Constructor to initialize a node.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares this node to another node based on their f values.
    boolean
    Checks if this node is equal to another object.
    int
    Generates a hash code for this node.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Node

      public Node(int x, int y, int g, int h)
      Constructor to initialize a node.
      Parameters:
      x - The x-coordinate of the node.
      y - The y-coordinate of the node.
      g - The cost from the start to this node.
      h - The estimated cost from this node to the goal.
  • Method Details

    • compareTo

      public int compareTo(@NotNull AstarStrategy.Node o)
      Compares this node to another node based on their f values.
      Specified by:
      compareTo in interface Comparable<AstarStrategy.Node>
      Parameters:
      o - The other node to compare to.
      Returns:
      The comparison result.
    • equals

      public boolean equals(Object o)
      Checks if this node is equal to another object.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare to.
      Returns:
      True if the objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Generates a hash code for this node.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.