CS 111 - Introduction to Computing, Spring 2012

Lab 2

Running DrJava in the ACCC Labs

DrJava can be found on the machines in the ACCC Lab in SEL 2249 by
  1. clicking on the Start button (lower left corner of the display)
  2. clicking on the Programming folder
  3. clicking on the DrJava folder
  4. clicking on the DrJava RXXXX application (where XXXX is the release number of the software)
To run the software from the book, which includes the Turtle class and the World class for this assignment, you must download and use the bookClasses library.

Step 1: Download the bookClasses zip file: http://coweb.cc.gatech.edu/mediaComp-plan/uploads/101/bookClasses-3-9-10.zip

Step 2: Unzip the file by right-clicking on the downloaded zip file and choosing Extract. Keep track where the unzipped folder is stored on the machine.

Step 3: Now open the Preferences window in DrJava, by clicking on the Edit menu item and selecting Preferences. In the Preferences window, click the Add button next to the Extra Classpath line. Find and select the bookClasses folder that was just unzipped. NOTE: you are looking for the folder bookClasses not the bookClasses-3-9-10 folder! Finally, click the OK button on the Preferences window to save your changes and exit the Preferences window. Refer to section 2.2 of the book for another description on how to do this.

Lab Assignment

Due: Wednesday 2/6/2013 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. After the turtle has drawn your initials, show them.

    This lab assumes your initials have 3 letters. If you don't have three letters for your initials, add a number or some other symbol 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. You don't need to follow my plan exactly, but I think it works fairly well. 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. This is done by using the penUp() and penDown() methods of the Turtle class. Refer to the JavaDocs for the bookClasses page for more information.

    Also, remember to change the color of the pen. 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". 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 word "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 turtle "turtle1" draw with the color red you would use the code:

    turtle1.setPenColor ( Color.RED );
    Also you can check out the code we did in class that draw lines in different colors. That code is Lect0913d.java .

  2. Be sure to include a comment at the top of your java file that contains the following:
    • your name
    • your NET-ID
    • day and time of your CS 101 lab section (i.e. Monday at 2:00)
    • A description of the project.
This information is a part of Good Programming Style. Leaving off this information will cause you to get less than full marks for this lab assignment.

Submission of the Lab

Use the Lab 2 submission link in the Assignments Page of Blackboard for CS 111. You will only need to submit the java source code file. You are to name your file (and also the public class in your program) with both the lab number and your NetID so we can find it easier. For someone with the NetId of tsmith14 the file should be named:


This topic: CS111 > WebHome > CS111Spring2013 > AssignmentsS13 > Lab2S13
Topic revision: r1 - 2013-01-31 - 18:12:59 - Main.troy
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
Helping Women Faculty Advance
Funded by NSF