CS 101 - Intro to Computing, Spring 2008

Lab 3

Lab Assignment

Due: Thursday 9/18/2008 by 11:59 pm

For this lab assignment, complete the following:

  1. Using a single turtle, write out your initials on an image/world. Each letter needs to drawn in a different color. This lab is assuming your initials have 3 letters. If you don't have three letters for your initials, add a number to get it to at least three initials.

    The key to this lab is to write the letters using very "blocky" upper case letters. For example:

    I made letters that were 100 pixels high and 50 pixels wide. I also put a space of 25 pixels between each letter and left a space of 25 pixels around the border. I also set the width of the pen to be a little thicker than the default size of 1 pixel wide. Remember to keep the pen up between letters and to change the color of the pen. This is done by using the penUp() and penDown() methods of the Turtle class. Refer to the JavaDocs for the bookClasses page to more information.

    To use color, you will need to add an import statement at the top of you program. This statement will add in the Java Color class from the Java-AWT library:

    import java.awt.Color;
    AWT stands for the "Abstract Windowing Toolkit". We did state in class that you could import the entire AWT library if you wished without causing any undo harm to the program but it is not really needed in this case. To do this, you would replace the work "Color" with an asterisk "*".

    Once you have added the import statement, you specify the color of the pen using the setPenColor() method from the Turtle class. The parameter will be the color you wish to use. The parameter will be given as: Color.xxx where xxx is the name of the color you wish to use. Note: the color names need to be defined in the library first. To find the defined color names check out the Java Sun Web Page on Color. The values is listed in the "Field Summary" section.

    For example, set have the turlte "turtle1" draw with the color red you would use the code:

    turtle1.setPenColor ( Color.red );

  2. Be sure to include a comment at the top of your java file that contains the following:

  3. You are to submit the Java file electronically by placing it in the Digital Drop Box inside of Blackboard. You only need to submit the java source code file. Please make sure you identify your submission with the name of Lab 3.

  4. You are also to submit a hardcopy of your java source code file. You can