• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TurtleGraphics error

 
Vitor Mateucci
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i tryed to write this project from my java book

but when i excecute the program i get errors saying that the pacage TurtleGraphics does not exist, now i have Jdk1.7.0 installed has any one runned into this problem before?
 
Tim Moores
Bartender
Posts: 2839
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JDK does not contain a "Turtlegraphics" package - that is probably something that was written by the authors of the book. You need to locate that (the book should tell you where you can get it), and add the relevant jar files to your classpath during compilation and runtime.

At a quick glance, it should contain at least a "StandardPen" class (which your code uses), but most likely more than that.

I note that your code does not have a "main" method, nor does it seem to initialize any GUI objects on which to draw; is the Turtlegraphics package supposed to handle that, or is the code not yet finished?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49370
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there is a design error in that class, too. I think having a no-arguments constructor is mistaken. I don’t think you want to default to 0, 0. I would suggest you get rid of that constructor, and move the initialisation of pen and colour into the other constructor. Also consider whether you want a default colour; if not you would add a Color parameter to that constructor. And I would use the upper-case version of red: Color.RED. Upper-case is better style for constants. You can overload the constructor like that with a default colour, like this
 
Campbell Ritchie
Sheriff
Pie
Posts: 49370
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see I have a new and unusual spelling of SmilingFace
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic