CS 101 - Intro to Computing, Spring 2010

Lab 5

Lab Assignment

Due: Thursday 2/18/2010 by 11:59 pm

For this lab assignment, complete the following:

  1. Using the turtle drawing features, create an image that contains a set of concentric shapes. The shapes can be any that you want (squares, octagons, triangles, etc). For this lab, each smaller version of the shape must be completely inside of the next larger size of the shape. An example of this is using a square as follows:

    or

    or the following using a hexagon

    The above have the center of each shape in the same place while the following two do not have the center in the same place.

    or

    Your set should have the shape repeated at least 8 times with the sides of each shape being slightly longer that the one closer to the center. The loop variable that keep track of how many shapes to draw was used to calculate the length of each side.

    The key to this lab is to move the turtle to the proper location (with the pen UP!) after one shape is drawn and before the next shape is drawn. For the shapes shown above, the starting/ending point of each shape is the lower left corner. The turtle moves left by a certain amount and then down by that same amount to get in position to draw the next shapes.

    While you do NOT need to draw a square for this assignment, using a square is by far the simpliest way to complete the assignment.

  2. Your drawing of the shape MUST BE DONE IN ITS OWN METHOD! This method is to draw the shape once every time it is called. Thus to draw eight shapes, you will need to call this method eight times. Since the length of the sides of the shape must change with each drawing, you will also need to send the method a parameter that indicates the length of each side of the shape.

  3. The image for the drawing can initialy be blank or be an image selected by the user. After you are done drawing the image, you are to prompt the user for a filename and store the image in that file. You should use the pickAFile() method from the FileChooser class.

  4. Be sure to change comment with the name of the author to contain the following:

  5. You are also to submit the Java file electronically via the following steps:

    How assignments should be submitted

    1. Go to the blackboard site for the class
    2. Select "Assignments" on the left bar
    3. Locate the correct assignment to submit; click on "View/Complete Assignment" at the bottom of that assignment
    4. Next to "Attach local file", click "Choose file", choose the file you want to submit; please submit only ONE file, properly named.
      For example for lab2, name it Lab2yournetid.java, for example if your Net ID is sfranz3, the filename would be Lab2sfranz3.java
      Please only submit source code file (the .java file, not the .class). Also, if you have any comment about your program, please write it down in the same file; please do NOT write in the "Comments" field on the submission page (this will go into a different file and will be easily missed).
    5. Hit "Submit"
    6. Go back once again to View/Complete assignment and make sure that your file was submitted; also, this page will show your grade and comments (if any) after assignments are graded.