Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I see a variety of problems:</p> <ul> <li>You are initializing your Drunkard's position to 100,100. The assignment said to initialize to 0,0.</li> <li><code>System.out.drunkard.report()</code> absolutely does not compile. Just call <code>drunkard.report()</code>.</li> <li>The instructions say to print the final location, so you need to move the call to drunkard.report() down one line, so that it is outside of the for loop.</li> <li>You haven't written methods for moveSouth or moveWest. Write them and add calls to them in the appropriate place.</li> <li>The class Four needs to be public in order to run it directly.</li> <li>Good Java programming practices say that every class should be in its own file, but this probably goes against what your instructor asked you to do.</li> </ul> <p>But, I don't think that's your problem. I think there's a problem with how/where you're trying to run the program. You say it compiles fine but doesn't print any output. You know that after it compiles there is another step to run the program, right?</p> <p>To be clear, here's what you should be doing. At a command line, make sure you are in the directory where your <code>.java</code> file lives. I'm going to assume it's called <code>Four.java</code>. Type the following, hitting enter after each line. (Don't type the <code>$</code> prompt)</p> <pre class="lang-none prettyprint-override"><code>$ javac *.java $ java Four </code></pre> <p>I copied the code you posted above, fixed the problems I highlighted, and followed my own instructions above; it works perfectly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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