/** * Class for creating a template for a simple Java program * * @author Pat Troy: troy AT uic DOT edu */ // 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 import java.awt.*; public class Lect22a { public static void main (String[] args) { System.out.println("Begin Java Exection"); System.out.println(""); // create my turtles on a blank picture // Picture pict = new Picture (600, 400); // width = 600 pixel; height = 400 pixel // have the turtle draw on an existing picture String filename2 = FileChooser.pickAFile(); Picture pict = new Picture (filename2); Turtle t = new Turtle (pict); t.setPenWidth (5); // draw a square with my turtle t.forward (100); t.turn (90); t.forward (100); t.turn (90); t.forward (100); t.turn (90); t.forward (100); t.turn (90); //move turtle to a different location t.penUp (); t.turn (-90); t.forward (150); t.turn (90); t.penDown(); // draw a blue triangle with my turtle t.setPenColor(Color.blue); t.forward (100); t.turn (120); t.forward (100); t.turn (120); t.forward (100); t.turn (120); //move turtle to a different location t.penUp (); t.turn (-90); t.forward (150); t.turn (90); t.penDown(); // draw a red triangle with my turtle t.setPenColor(Color.red); t.forward (100); t.turn (60); t.forward (100); t.turn (60); t.forward (100); t.turn (60); t.forward (100); t.turn (60); t.forward (100); t.turn (60); t.forward (100); t.turn (60); // display the picture with the turtle pict.show(); // code to save the picture String filename = FileChooser.pickAFile(); System.out.println ("Filename: " + filename); pict.write(filename); System.out.println(""); System.out.println("End Java Exection"); } } // end of Template class