Required Working Style for Today's Lab:
- BEFORE YOU START, arrange yourselves so that you are sitting beside people you don't usually sit beside.
- From beginning to end you will work in a folder which contains all your work for today's lab.
- Before you leave, you will email me all the files necessary to run your application(s). Do not DELETE programs to work on new ones. Make a new file for each new exercise. At the end of lab, I want to have *everything* you worked on today in lab.
This should always be the case and done for all labs!
If you like, your classes need not be graphical. That is up to you, though I, personally, think graphical is the way to go! If you agree and "go graphical", you must think carefully about your a base case and the recursive portion of your code.
For this assignment you need to demonstrate your understanding of recursion -- either functional or structural(ie, probably graphical as in...drawing StdDraw shapes).Work on your understanding of recursion and try to have fun.
Once you think you have the hang of recursion, think about combining concepts....
2.3.27 Sierpinski triangles.Write a recursive program to draw Sierpinski triangles. As with the 'H' drawing program we saw in class this morning, use a command-line argument the a default n value of 1 to control the depth of the recursion. (A value of 1 for n should draw a single equilateral triangle.)
![]()
2.3.30 Brownian island.B. Mandelbrot asked the famous question How long is the coast of Britain? Modify Brownian program from your text (p.279) so that drawn output is a Brownian Island rather than a jagged line from left to right.
- first, change curve(...) to add a random Gaussian to the x-coordinate as well as the y-coordinate. Compile & make sure it works!
- next, change main(...) to draw a curve from the point at the center of the canvas back to itself. Experiment with various values of the parameters to get islands with a 'realistic-look'.
![]()
(Note: Brownian code in book is EXACTLY like the RandomWalkClient code we looked at this morning, but uses 2 extra parameters to control the amount of smoothness by calls to StdRandom.gaussian(...) rather than the simpler calls to Math.random() calls.)
2.3.33 Recursive tree.Write a program TreeClient that takes a command-line argument n and produces the following recursive patterns for n equal to 1,2,3,4, and 8.
Prof.Dale's personal favorite, (-:
(TreeClient_1234.class![]()
Like... really favorite, (-:
In the code that generated the next image, I used transparent but consistent colors for each of the left, center, & right branches & changed the scale to draw tree with n=8 again. Doing so makes the recursion easier to... see. Notice all the trees also have differing pen radii so that smaller branches are drawn more finely. SO FUN!![]()
*/ ?>