Introduction
to Programming
Java
Turtle Graphics
TurtleGraphicsWindow. When you extend it, you inherit
all of the methods it provides. It gets you all of the
graphics-oriented commands and operators you've been using in TG.
Here is the JavaDoc documentation of the methods that are available.
To use the Turtle Graphics stuff, you will need to download a few Java sourcecode files to your system and compile them. The files you need are:
TGKeyHandler.java
TGMouseHandler.java
TGPoint.java
TGGraphicsOp.java
TGFillOp.java
TGLabelOp.java
TGLineOp.java
TGCanvas.java
Turtle.java
TurtleGraphicsWindow.java
class cross extends TurtleGraphicsWindow
{
public void myTurtleCmds( )
{
forward( 100 );
back( 200 );
forward( 100 );
right( 90 );
forward( 100 );
back( 200 );
}
// program starts here
public static void main ( String[ ] args )
{
cross obj = new cross( );
obj.myTurtleCmds( );
}
} // end class cross
|
| Example 20.1 |
Type it in; compile it; run it.