Assignment 3
CSC 115 -- Fall 2002
Objectives:
- An introduction to the Model/View Pattern which separates the
application's user interface and underlying data
- Experience using recursion.
- An introduction to Java graphics components and methods.
- An introduction to Turtle graphics
- Interpretation and understanding of existing code.
- Ongoing documentation and style practice.
Introduction:
This fun assignment allows you to experience
the creation of some very pretty simple graphics using both recursion and a
"turtle". The turtle is a simple object that simply knows a point on a screen.
It draws lines by moving from its current point to another, adopting the last
point as its current position. It is analogous to drawing on paper without ever
taking the pen off the paper. The curves in the assignment belong to the set of
fractal drawings. Fractals use recursive techniques to apply a formula to
each "piece" of a previous curve. A demonstration of the turtle churning out
these curves will be presented in the lab classes. Be sure you attend.
Requirements:
- Create a UML class diagram of this program.
- Finish the Sierpinski routines C and D and makeCurve.
- Program the cross curves recursively using the given class
structure. That is, write two classes Cross and
DrawableCross, where DrawableCross should extend Cross and implement the
interface DrawableCurve
- Add the Cross Curve as another curve on the frame that is instantiated
with SpaceFill (you also need to extend the user interface to include
Cross as an option).
Recursive Construction Rules:
These pages illustrate the
recursive construction rules for the curves we are using in this project:
(please note that the graphic y-axis points down, as opposed to the
mathematical y-axis, which points up).
- Hilbert
Curves
- Sierpinski
Curves
- Cross
Curves
The following code is given to you and, except for
the SpaceFill.java addition, should not be altered. You can compile and run
SpaceFill, it just isn't finished for the Cross curve:
Rules & Hints
- When you have completed the assignment, running javadoc on the files
should produce something like this API.
- Start by looking over the existing code, and determining the nature of the
design. The class diagrams will help you.
- To understand the recursion, start by looking at the Hilbert and
Sierpinski curve description. Try making various changes to the code to see
what happens.... this will help you understand it.
- Attend the labs, and bring your questions there.
And the regular.....
- Headers must contain your name and/or your student number.
- The javadoc
commenting style is to be used. These are the comments that define the
purpose, input, and expected output of each of your public methods and
classes. Text, lecture, and lab examples are a good introduction.
- The regular
comments must contain instructions for programmers who may have to modify
your code at some later date. These comments should help the programmer
understand what the code is doing in plain language. You can assume that the
programmer is intelligent to know what while loops and
if-statements are.
Due Dates and What To Turn In
There is no part A due for this assignment, but you are strongly encouraged
to attend the lab! This assignment is due by 6pm on Tuesday November 5th. Submit the following *.java
files electronically.
- Sierpinski.java
- Spacefill.java
- Cross.java
- DrawableCross.java
Instructor Note
If you find any errors or inconsistencies in this
document, report them immediately to csc115@csc.uvic.ca. Notification of changes
(or clarifications) will be posted on the csc 115 webboard and on the course web
page.