/** * Class for creating a template for a simple Java program * * @author Pat Troy: troy AT uic DOT edu */ // import the library with the color information import java.awt.Color; // Note the name of the class in the following line MUST // match the name of the file. This is stored in a file // named: Template.java public class Lect921c { public static void main (String[] args) { System.out.println("Begin Java Exection"); System.out.println(""); // Select a picture for the turtle to draw on Picture pict1 = new Picture(600, 600); // Create the turlte and place it in the world Turtle t = new Turtle (pict1); t.setPenWidth(5); t.penUp(); t.turn (-90); t.forward (250); t.turn(90); t.penDown(); // draw square #4 with the turtle drawShape (t, 30); // display the picture pict1.show(); // Save the picture //String fname; //fname = FileChooser.pickAFile(); //System.out.println ("File: " + filename); //pict1.write (fname); System.out.println(""); System.out.println("End Java Exection"); } // end of the method main // draw any regular polygon public static void drawShape (Turtle tParam, int numOfSides) { int degrees = 360 / numOfSides; int loopCounter; loopCounter = 1; while ( loopCounter <= numOfSides ) { tParam.forward (3); tParam.turn (degrees); loopCounter = loopCounter + 1; } } } // end of Lect914b class