CSE 115/503 - Spring 2011 - Banner
  • CSE 115/503 - Spring 2011
CSE 115/503 - Spring 2011 - Navigation
CSE 115/503 - Spring 2011 - Lab 5

Lab 5
Last modified: March 08 2011 09:37:32 AM

CSE 115/503 - Spring 2011 - Lab 5

Introduction

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.


Objectives

We will concentrate on the following idea that was discussed in class:

  • ActionListeners
  • Drawing graphics to the screen
  • Programs that react to user actions
  • Creating a program that is both an applet and an application

There will also be a review of the following two concepts previously covered:

  • Defining classes
  • Graphical components from javax.swing package
  • Creating objects
  • Calling methods
  • References


Lab Tasks

Eclipse Project Setup

Check out the Lab 5 Skeleton from the repository and set up the project so that you can begin creating source code.

Design

You will need to design your solution using UML before you begin coding. You will also be required to complete and submit a UML diagram named Lab5.grn with your final submission.


Assignment Description

Basic Components [20 points] Must complete before moving on

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 components to your program to earn a better grade.

 

Additional Components [80 points possible]

Think carefully about the type of components you will need to add to your program for the following functionality. You should add each piece of functionalty ONE AT A TIME and make sure it is working before moving on to the next piece. The order that these are described here are not necessarily the order you should implement them in. You should implement the functionality in a way that makes the most sense to you.

[A] Click on drawing canvas and the turtle goes there [5 points]

[B] Button that causes the turtle to go to a random point on the drawing canvas [5 points]

[C] A component to erase all the drawings from the canvas. [5 points]

[D] A component to send the turtle back "home" - to the center of the drawing canvas. [5 points]

[E] Allow the user to rotate the direction in which the turtle is facing. [8 points]

[F] 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]

[G] 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]

[H] 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 shape will appear in that color. [8 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. [10 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. [16 points]

[I] Implement the drawing of a second type of shape using thes same mechanism as the first. [10, 8, 5, 3 points depending on option used for shape drawing]

[J] Borders (Can only receive credit for one of the following two options)

(1) 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]

(2) 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]

 

Advanced Components

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).

 


Due dates

You will submit your Lab 5 assignment using the Web-CAT submission plugin from Eclipse. (At this time, the grading is not enabled for this assignment, so EVERYONE will receive a zero when submitting the assignment.) The entire lab work will be due the last day of classes before spring break starts, Friday, March 11th at 9:00pm.

Recitation Due Date
All Monday, March 21st at 11:00pm

 


CSE 115/503 - Spring 2011 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@buffalo.edu | 130 Bell Hall | (716)645-3184