• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Please critique!

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try compiling it on the command line, there's a fairly obvious mistake on one line.
 
richard rehl
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Harold, tried compiling on the command line, no errors reported, compiled and ran just fine....
 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's odd, it doesn't compile for me.

Line 63 is the problem.
 
richard rehl
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;'.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic