• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Maze Solving

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm having trouble with my current program here. We are supposed to find a path out of a maze using a coordinate class. We have to create coordinates and then push them onto a stack. At the end we have to pop the stack to get the path coordinates. I am having problems backtracking in my while loop. I can get all the way to that but when it hits a dead end I can't figure out how to pop the stack and take the coordinates from the previous space and apply them to the loop. If anybody could help me out that would be great. I have included the coordinate class as well as some sample mazes. Thanks.

I think the problem is in this while loop (line 152)

Program Maze....

Coordinate class...


DynamicStack class
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is a lot of code to go through and in all fairness I haven't. But I have a remark:

Do not catch ArrayIndexOutOfBoundsExceptions. Just ask the size of the array and operate in those bounds.
And if you really really really want to catch it then at least log it, otherwise you'll never know about the exception.
 
Ranch Hand
Posts: 96
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the class DynamicStack you declare 'head' to be of type 'Node'. What class is this 'Node'? You didn't add one to your code ..

Wim
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic