Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help with logic error

 
Randall Twede
Ranch Hand
Posts: 4442
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have resisted posting this for days thinking i could solve it but i cant seem to get anywhere

i will explaint the program and the problem first then post the relevant code.

the program creates an array of ToggleButtons and a stack of Points. the user builds paths throught the maze by clicking(selecting) the toggle button, which turns their icons from water to wood. after the mazed is built, the user "releases the rat". squares that get visited become disabled(turning the icon to fire). if a dead end is reached(the final else of the while loop) the disabled icon gets changed to wood. this all works fine for certain paths, however if the dead end branches, all the icons back to where dead end branched off get turned to wood except the square at the intersection of the branches. also if there is no path through thr maze, all icons get turned back to wood except branch intersections and the very first square .

here is the code. as you will see from the commented out lines i have been trying to figure it out.



i almost posted this in the programming diversions forum but it is more like a headache than a diversion

sorry the code didnt copy and paste perfectly, but it is pretty readable.
 
Randall Twede
Ranch Hand
Posts: 4442
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i solved one of the problems. it was obvious. when there is no path through the maze it pops points from the stack till the stack is empty. when the last point is popped, execution exits the while loop without changing the image on the first toggleButon. i just had to add one line of code.

the other oroblem is proving very elusive. i wish i knew how to use the debugging tools in eclipse and wish their help was more helpful
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic