File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes need help with logic error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "need help with logic error" Watch "need help with logic error" New topic

need help with logic error

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340

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.

Visit my download page
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340

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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: need help with logic error
Similar Threads
moving through 2D arrays
LEJOS :: Maze Solver
Maze Solving
July Newsletter Puzzle (Maze Solver)
a very elusive bug