In this lab, you will be re-creating a computer drawing environment from the early days of personal computing - turtle graphics. You will be writing a program that allows the user to control how and what the turtle will draw.
We will concentrate on the following idea that was discussed in class:
There will also be a review of the following two concepts previously covered:
Check out the Lab 7 Skeleton from the repository and set up the project so that you can begin creating source code.
Attendance will be taken for this lab and will count towards part of this lab's grade.
You will need to design your solution using UML before you begin coding. You will also be required to submit a UML diagram named Lab7.grn
with your final submission.
The premise of turtle graphics is that there is a turtle on the screen when the program begins. The user of the program can then use the turtle to draw various things to the screen by issuing the turtle commands (using the buttons and menus provided by the program).
To begin, you must create a program that has a turtle appearing on the screen. The turtle should appear in the center of the drawing canvas it is on and the drawing canvas should be set to a specific size in your program. The "turtle" on the screen can be any type of visual image you'd like, a simple circle or rectangle or a full-blown image.
After this is complete, you can begin to add additional component to your program to earn a better grade.
For each of these, it should be as clear to the user as possible what each graphical component does. If the grader can not determine what functionality you implemented or how to use your program, you will not receive credit for that component.
Click on drawing canvas and the turtle goes there [5 points]
Button that causes the turtle to go to a random point on the drawing canvas [5 points]
A component to erase all the drawings from the canvas. [5 points]
A component to send the turtle back "home" - to the center of the drawing canvas. [5 points]
Shape Drawing (Can only receive credit for one of the following four options)
(1) Draw a selected shape at the location where the turtle is, color and size fixed by the programmer [5 points]
(2) Draw a selected shape at the location where the turtle is based on a color inputted through radio buttons by the user (that is, the user will select a color from a fixed set of colors and the turtle's shape will appear in that color. [10 points]
(3) Draw a selected shape at the location where the turtle is based on a color inputted as above and a size inputted through another user interface mechanism so that the size and color of the shape is controlled by the user. [15 points]
(4) Draw a selected shape at the location where the turtle is based on a color inputted through a JColorChooser and a size inputted as above, so the choice of color for the shape is not from a set of colors provided by the program. [23 points]
Implement the drawing of a second type of shape using thes same mechanism as the first. [13, 8, 5, 3 points depending on option used for shape drawing]
Implement the drawing of a shape where the user can select to add a black border to the shape. (Basically have one button for drawing the shape with no border and another for drawing the shape with a black border). [8 points]
Implement the drawing of a shape where the user can choose a color for the border of a shape. (Essentially the same as above, but the second button should create a JColorChooser for the user to select border color from). [10 points]
Allow the user to rotate the direction in which the turtle is facing. [8 points]
Allow the user to see this rotation by a visual clue on the image (examples would include an arrowhead, but there are other options). [8 points]
Program a button or other component to draw a series of shapes so when the user selects that option, a simple drawing appears. [8 points]
This component should be considered extra credit and only attempted if you can do the most difficult of the implementations mentioned in additional components. If you complete it and not others from the list above, you will still get the credit, but since I would consider it harder than the ones above, inability to complete the above would be an indicator that you shouldn't attempt this extra credit.
Drawing Lines [20 points]
Originally the turtle was a line drawing program. The turtle carried around a pen which could be positioned up or down. If the pen was down, whenever the turtle roamed about the screen, it would leave a line behind it to show the user its path. You can choose to implement all of this functionality (drawing lines as the turtle moves, pen up and pen down).
The Lab7.jar
must be submitted using the electronic submission command the evening before (11:59:59pm) your lab session in two weeks, the due dates are summarized in the table below. Note that your submission must include your Java source code files as well as a file that contains your UML diagram.
Recitation Normally Meets on | Assignment due on |
Tuesdays | Monday, November 3 |
Wednesdays | Tuesday, November 4 |
Thursdays | Wednesday, November 5 |
Fridays | Thursday, November 6 |
Lab authored by Adrienne Decker
Page maintained by Adrienne Decker
Contact: adrienne@cse.buffalo.edu | 130 Bell Hall | (716)645-3180 x 161