First Assignment

"If you please, draw me a fractal (*)."

In this assignment you will be asked to draw a Sierpinski Gasket and a Sierpinski Carpet fractal. The drawing of this sort of fractal is based on recursion. By recursion we mean something that uses itself to define itself. E.g. "GNU acronym stands for: 'GNU is Not Unix'". That first example is of course a bad hacker joke. More Seriously, you can define the mathematical value of factorial n (which is n(n-1)(n-2)... 2 * 1 ) by :

Find in the attached paper the definition of a Sierpinski Gasket. Here is a general idea of what it looks like when starting the iteration with a rectangle:

level 3

level n with n > 10


Ground Rules for all projects:

To submit a project...

you should put altogether, in a directory called COMPXXXX_A1_UstudentID...

(Where XXXX is the right lecture code (6461 or 4610) and 'studentID'... your student ID !)

Use the jar command to put your directory into a single jar file based on the same name and mail this file to

cd .. (go to the directory in which your COMPXXXX_A1_UstudentID is located)
jar cvf COMPXXXX_A1_UstudentID.jar COMPXXXX_A1_UstudentID/

Mail the file (COMPXXXX_A1_UstudentID.jar) as a attached document. Be sure that the title of your mail is 'CGA1:COMPXXXX_A1_UstudentID.jar'

The minimum requirements

Your project should be composed of, at least, the following :

(1) One abstract class. You should put (declare and or implement) as many as possible things that are common to what is necessary to write a recursive fractal in that class. This class could, for instance, extend a JPanel ( or a JFrame, depending on the architecture you choose). One could imagine that the method that make the class 'abstract', is for instance, the one that will draw a given level of a given type of fractal ( abstract protected void buildElement(double xmin, double ymin, double xmax, double ymax, int level, Color color, Graphics g) for instance);

(2) Two public classes that will implement respectively a Sierpinski Gasket and a Sierpinski Carpet.

(3) One public class, whose name will be "Assignment" and that will contain the "main method" in such a way to test your project, I will only need to call 'java Assignment [command line arguments]' to run it. Because yours classes will be well documented, I should be able to write that "Assignment" class by myself without to much work.

(4) You will explain the use of the arguments in your README file but the two first one will be gasket|carpet IterationNumber

Eg : java Assignment gasket 7
will draw the 7th level of a Sierpinski Gasket

(5) Remember that sometime, users may be dumb and may not use the right number of of argument.

(6) Remember that again, users may be dumb and could use a very high Iteration Number. It could be a good idea to have 2 trivial criteria to end the recursion. One is the number of iterations, the other one is...(this is the sort of thing -amongst others- that should appear either in your code comments and in the README file)

(7) One peculiarity of these fractal displays is that the panel should be resizable (whenever the size of the window is changed by the user, the fractal should be redrawn in order to fit in all the available space).


Optional stuff that will impress:

You should do at least one of theses option to get the maximum mark


(*) If you didn't know that the original quotation was about a sheep, you should perhaps first read "The little prince" story before beginning to do computer graphics.