Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There's a lot of good advice in the comments; I'll just try and summarize them as best I can.</p> <h3>MePePeR's Advice: Use one method call</h3> <p>Transform your individual <code>goXXXX()</code> calls into a single <code>go(dx, dy)</code> call. If you are trying to tackle recursion (as your question suggests), you should probably be pretty familiar with writing your own methods first. Notice that each <code>goXXXX()</code> method is almost identical, except in each one you modify the <code>currCol</code> and <code>currRow</code> variables. If you pass in the amount of change as parameters (i.e., the change for <code>currCol</code> as <code>dx</code> and the change for <code>currRow</code> as <code>dy</code>), you can use the same method over and over, just giving it different values. A move east would be <code>go(1, 0)</code>, a move south would be <code>go(0, -1)</code>, etc. </p> <p>If you aren't very comfortable with passing parameters, just give it a try, post the updated code and we can guide you through issues you encounter.</p> <h3>Hot Lick's advice: Use a debugger.</h3> <p>You've already taken the first step here with your <code>printMaze</code> method. If you aren't developing in an IDE (I didn't when I first started learning), debuggers can be a little hard to use. In that case, you'll need to simply use more <code>System.out.println</code> statements to get more information on the execution of your code. If you <em>are</em> using and IDE, start trying out the debugger. They're really easy to use once you start playing around with them. Once again, if you get stuck, talk to us and we can help guide you.</p> <p>One last pointer: notice that your maze printout has this:</p> <pre><code>xVVx PPVx xPxx </code></pre> <p>Since you are only supposed to go north, south, east or west into a free space, how are you able to get a <code>V</code> in the upper right corner? It's an indication that your code is possibly either marking the wrong cell, or allowing a move that's illegal.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload