0

I have this code and I am trying to have my on_path method reference the variable first but the compiler says cannot find. I have it declared not sure why its not recognized?

public class hmwkr6
{
  private static final int size = 5;
  private static final int wall = 1;
  private static int open = 0;
  private static int[][] walls = {
    {0, 0, 0, 0, 0},
    {1, 1, 0, 1, 1},
    {1, 1, 0, 1, 1},
    {0, 0, 0, 0, 0},
    {0, 1, 1, 1, 0}};
  private final int dest_row = 4;
  private final int dest_col = 0;
  
  class square
  {
    int row;
    int col;
    square(int row1, int col1)
    {
      row = row1;
      col = col1;
    }
  
   class path
  {
    square first;
    path rest;
    path(square first1, path rest1)
    {
      first = first1;
      rest = rest1;
    }
  
   
  public boolean on_path(square sq1, path p)
  {
  for(int i = 0; i<walls.length; i++)
  {
    if(square.first==0)
    {
      return true;
    }
    if(square.first==1)
    {
      return false;
    }
    else{}
      
  }//end while
    }//end method
   }
  }
}
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ezzaral
0

You have "first" defined as a member of the "path" class, not of the "square" class. Also, you are using the class name, rather than the parameter name, in your on_path() method.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.