This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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?
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
Joined: Oct 13, 2005
I see I have a new and unusual spelling of SmilingFace