View the step-by-step solution to:

# G51PRG Semester Two Large Coursework One 2009/2010 Revision:10 This coursework is worth 15% of the total mark for this half of the module. When...

File is attached, I need solution in 3 days. Thanks

-2- 2. Implementation When fnished, your program should be able to be called like this: java LSystem <filename> <iterations> where <filename> is the name oF the fle that contains the description oF the L-System, and iterations is the number oF times to process the input string in order to generate the string that is actually used to draw the Fractal. Other than that, how you structure your program is up to you. You can use as many or as Few objects as you decide although you should justify your reasons in your report. 2.1. Displaying the Fractal This is the simpler part oF program, and so probably the best place to start. To display the Fractal on screen you will need to open a window (size 640 by 480 pixels) on screen containing a custom JComponent object. Your JComponent object will be responsible For drawing the Fractal in the window. To do this, we will use the notion oF ‘Turtle Graphics’ to draw things. This method is based around the idea oF a ‘turtle’ which is given instructions to move and as it moves it draws a line. The turtle can be told to move Forward or to turn to the leFt or the right by a specifc angle. IF the turtle turns then any Further movement happens along this axis. How you implement this is up to you. You could either investigate the Java Graphics2D object’s methods a bit more, or you may decide to calculate the angles involved yourselF (using Math.sin and Math.cos — but remember these work in radians rather than degrees). The initial start position and direction oF the Turtle is up to you, but you should aim to position it so the Fractals ft as nicely as possible in the window * . The same applies to how Far the turtle moves with each step. The actual drawing is done by considering the string generated by the L-System chacracter by character. Certain characters in the string will be interpreted as actions to make the turtle move, while other characters will be ignored. The characters with meaning are listed in the table below: Character Meaning A , B , F , G IF any oF these characters are encountered in the string, then the turtle should move Forward (in the current direction) by a fxed amount. (The amount the turtle moves is up to you, but see the comment above.) - This rotates the turtle to the leFt by a certain amount. The amount to turn is specifed on the frst line oF the fle describing the L-System (in degrees). + This rotates the turtle to the right by a certain amount. The amount to turn is specifed on the frst line oF the fle describing the L-System (in degrees). [ Save the current graphics state. That is the cur- rent position and direction oF the turtle. Multiple states can be saved and the are restored in a Last In, ±irst out Fashion. Advanced Feature only. ] Restore the graphics state saved previously with a ] . Advanced Feature only. * Do this in general, you should not be optimizing the position For each L-System.
Show entire document

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents