/** * A simple Turtle drawing program * * @author Pat Troy: troy AT uic DOT edu */ // add import statements to get items from Java libraries import java.awt.Color; // Note the name of the class in the following line MUST // match the name of the file. public class Lect0913a { public static void main (String[] args) { System.out.println("Begin Java Exection"); System.out.println(""); // put your Java Program here // Step 1. Create the world World w; World w2, w3, w4, w5; w = new World (); // Step 2. create the turtle Turtle t; t = new Turtle (w); Turtle t2; t2 = new Turtle (50, 150, w); // step 3. Move the turtle t.setPenWidth(5); t2.setPenWidth(15); // draw a square t.forward (150); t.turn (90); t.forward (150); t.turn (90); t.forward (150); t.turn (90); t.forward (150); t.turn (90); // example of a while loop int count; count = 1; while ( count <= 8 ) { t2.forward (50); t2.turn (45); count = count + 1; } // move turtle t to another part of the world t.penUp(); t.turn(180); t.forward (20); t.penDown(); // draw a triangle int numSides; int degrees; numSides = 5; degrees = 360 / numSides; count = 1; while ( count <= numSides) { t.forward (100); t.turn (degrees); count = count + 1; } // Final step, Show the world the turtle lives in w.show(); System.out.println(""); System.out.println("End Java Exection"); } } // end of Template class