/*
 * A Node wraps a Cell from the Map and includes
 * links to the neighbouring Nodes.
 */

public class Node
{
    public Node (Cell theCell)
    {
        _theCell = theCell;
    }

    public boolean hasBeenVisited ()
    {
        return _visited;
    }

    public void markAsVisited ()
    {
        _visited = true;
    }
    
    public Node getUp ()
    {
        return _up;
    }

    public Node getDown ()
    {
        return _down;
    }

    public Node getLeft ()
    {
        return _left;
    }

    public Node getRight ()
    {
        return _right;

    }
    public void setLinks (Node up, Node down, Node left, Node right)
    {
        _up = up;
        _down = down;
        _left = left;
        _right = right;
    }

    public Cell getCell ()
    {
        return _theCell;
    }

    @Override
    public String toString ()
    {
        String str = "Node: "+_theCell+"\nUp link: ";

        if (_up == null)
            str += "empty";
        else
            str += _up.getCell().position();

        str += "\nDown link: ";

        if (_down == null)
            str += "empty";
        else
            str += _down.getCell().position();

        str += "\nLeft link: ";

        if (_left == null)
            str += "empty";
        else
            str += _left.getCell().position();

        str += "\nRight link: ";

        if (_right == null)
            str += "empty";
        else
            str += _right.getCell().position();

        return str;
    }

    @Override
    public int hashCode ()
    {
        return _theCell.hashCode();
    }

    @Override
    public boolean equals (Object obj)
    {
        if (obj == null)
            return false;

        if (this == obj)
            return true;
        
        if (getClass() == obj.getClass())
        {
            Node temp = (Node) obj;

            return temp._theCell.equals(_theCell);
        }

        return false;
    }

    private Cell _theCell = null;
    private Node _up = null;
    private Node _down = null;
    private Node _left = null;
    private Node _right = null;
    private boolean _visited = false;
}
@@ -106,16 +106,188 @@
  Node%0A%7B%0A
+    public static final int UP_NODE = 0;%0A    public static final int DOWN_NODE = 1;%0A    public static final int LEFT_NODE = 2;%0A    public static final int RIGHT_NODE = 3;%0A%0A
     publ
@@ -520,202 +520,625 @@
 ode 
-getUp ()%0A    %7B%0A        return _up;
+tryAdjacentNode (int direction)%0A    %7B%0A        Node nextNode = null;%0A
 %0A    
-%7D%0A%0A
     
-public Node getDown (
+switch (direction
 )%0A    
+ 
-%7B%0A        return _down;%0A    %7D%0A%0A    public Node getLeft ()%0A    %7B%0A        return _left;%0A    %7D%0A%0A    public Node getRight 
+   %7B%0A            case UP_NODE:%0A                nextNode = _up;%0A                break;%0A            case DOWN_NODE:%0A                nextNode = _down;%0A                break;%0A            case LEFT_NODE:%0A                nextNode = _left;%0A                break;%0A            case RIGHT_NODE:%0A            default:  // assumption! could give error message%0A                nextNode = _right;%0A                break;%0A        %7D%0A        %0A        if (nextNode != null)%0A        %7B%0A            if (!nextNode.hasBeenVisited
 ()
+)
 %0A
+        
     
@@ -1151,30 +1151,134 @@
     
-return _right;%0A
+        if (nextNode.traversable())%0A                    return nextNode;%0A            %7D%0A        %7D%0A%0A        return null;
 %0A    %7D%0A
+%0A
     
@@ -1433,32 +1433,282 @@
 = right;%0A    %7D%0A%0A
+    /*%0A     * Only check space is not a wall (for now).%0A     */%0A%0A    public boolean traversable ()%0A    %7B%0A        if (_theCell != null)%0A        %7B%0A            if (!_theCell.isWall())%0A                return true;%0A        %7D%0A%0A        return false;%0A    %7D%0A%0A
     public Cell 

Update Node.java