File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes TurtleGraphics error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "TurtleGraphics error" Watch "TurtleGraphics error" New topic

TurtleGraphics error

Vitor Mateucci

Joined: Oct 06, 2011
Posts: 13
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

Joined: Sep 21, 2011
Posts: 2413
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

Joined: Oct 13, 2005
Posts: 46337
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

Joined: Oct 13, 2005
Posts: 46337
I see I have a new and unusual spelling of SmilingFace
I agree. Here's the link:
subject: TurtleGraphics error
It's not a secret anymore!