File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Please critique! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Please critique!" Watch "Please critique!" New topic
Author

Please critique!

richard rehl
Ranch Hand

Joined: May 21, 2007
Posts: 36
Here's a really crude exercise in turtle graphics, from Deitel (Java How to Program). The assignment (chapter 7, ex. 21) is to write a turtle graphics program that will draw a square using the commands given by the author. I know that there are better ways to input/store the commands than an array but my constraints are that I haven't really worked through Arraylists or other collections yet, and, I'm trying to first stick to the assignment. Although Eclipse complains that there are errors, the program compiles and runs; I don't know what the errors are. Thanks for looking!

p.s. I'm also aware that turtle graphics can do much more than draw squares and rectangles... again, I'm just trying to do the exercise as given


Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
Try compiling it on the command line, there's a fairly obvious mistake on one line.
richard rehl
Ranch Hand

Joined: May 21, 2007
Posts: 36
Hi Harold, tried compiling on the command line, no errors reported, compiled and ran just fine....
Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
That's odd, it doesn't compile for me.

Line 63 is the problem.
richard rehl
Ranch Hand

Joined: May 21, 2007
Posts: 36
The for loop declaration? I'm not getting an error message there... is it something to do with using cmds.length as the loop test?
richard rehl
Ranch Hand

Joined: May 21, 2007
Posts: 36
wow, that's weird - just looked at the code that I posted and see which is NOT in my compiler code! A gremlin?

I tried retyping line 63:
and still get
Errors exist in required project: Ex7_21. Continue launch?
from Eclipse.

If you fix that line, does it compile for you?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18757
    
  40

Harold Lime wrote:That's odd, it doesn't compile for me.

Line 63 is the problem.


That error is a known Javaranch problem -- there is some obscure issue that corrupt code, as it is being posted.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
My compiler, and my brain, although you're making me doubt the latter tell me that:

for (int i = 0; i >< cmds.length; i++) {

}

does not make sense, specifically 'i >< cmds.length;'.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

richard rehl wrote:The for loop declaration? I'm not getting an error message there... is it something to do with using cmds.length as the loop test?


Can you confirm that the for loop in your first post looks EXACTLY character for character like one in your code? I think there was a text conversion problem when the code was posted.


Steve
Harold Lime
Ranch Hand

Joined: Jul 20, 2009
Posts: 38
Henry Wong wrote:
Harold Lime wrote:That's odd, it doesn't compile for me.

Line 63 is the problem.


That error is a known Javaranch problem -- there is some obscure issue that corrupt code, as it is being posted.

Henry


Ah, in that case I can't see anything wrong. It compiles and runs, no errors and no warnings.
richard rehl
Ranch Hand

Joined: May 21, 2007
Posts: 36
Steve Luke wrote:
richard rehl wrote:The for loop declaration? I'm not getting an error message there... is it something to do with using cmds.length as the loop test?


Can you confirm that the for loop in your first post looks EXACTLY character for character like one in your code? I think there was a text conversion problem when the code was posted.


I can safely say that line 63 as posted is NOT like the line in my compiler code. When I add that > token to the line, Eclipse gives me an error message
Syntax error on token "<", delete this token
.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Wow, I kind of feel silly with how long it took me to post my previous reply. Must have been more than a minute...
 
Consider Paul's rocket mass heater.
 
subject: Please critique!