GeeCON Prague 2014*
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
Author

TurtleGraphics error

Vitor Mateucci
Greenhorn

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
Rancher

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

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

Joined: Oct 13, 2005
Posts: 39044
    
  23
I see I have a new and unusual spelling of SmilingFace
 
GeeCON Prague 2014
 
subject: TurtleGraphics error