Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let's first look at the final goal: Turtle Displayer Eile Help Turtle Canvas: Angle: -6.28... Location: (110, 110) Penis: Up Pen Colour Pen Width: 1

image text in transcribedimage text in transcribedimage text in transcribed

Let's first look at the final goal: Turtle Displayer Eile Help Turtle Canvas: Angle: -6.28... Location: (110, 110) Penis: Up Pen Colour Pen Width: 1 Close To achieve this, your Wallpaper program requires a drawwallpaper () method. That drawwallpaper must relocate the turtle to equidistant points, and draw 4x4 flowers. A flower, then, may be drawn via a drawFlower() method, such that: The flower is a random colour The flower is comprised of multiple petals It has a random number of petals, from 4 to 7 (inclusive) * Each petal is drawn as above: equiangular radiating from a single point at equal angles to each other Drawing a petal thus requires its own method, drawPetal(, to draw four lines like so: 30 T1/6 radians If you need a reminder on calculating the length of the hypotenuse for an isosceles right triangle, it's just the square root of double the square of the other side length (in this case, -21.2, but still calculate it) Tips and requirements Even though it's described in pieces above, those are just pieces within the same source file. (i.e. you don't need to submit multiple .java files) For the flower, remember that you're still turning around one full turn overall For the petal, it's imperative to have the turtle end in the same position angle as it started In case random colours haven't been covered in lab, you only need two things: import java.awt.Color; (to get the library) . pen.setPencolor (new Color((int) (Math.random() *16777216))); Though there are a couple places you could set the colour, there's only one correct spot Even though the petal is four lines, I'd advise against trying to put them into a loop; it's more trouble than it's worth Don't use parameters/arguments for your methods . (Depending on when you read this, you may or may not even know what that means) The entire point of this assignment is hierarchical decomposition (breaking down the problem into smaller pieces), so if you skip that step, don't be surprised if you get a zero Your final solution will probably be -60 lines of code. It isn't a challenging assignment, per se, but rather one that reinforces what you learned in lecture/lab/tutorial. It covers a fundamental technique in computer science. Give it the consideration and attention your entire academic future deserves Because you're using procedural abstraction, you might want to consider writing stubs to get the basic components together e.g. you might initially draw a 'petal' as simply a line (that then reverses to return to where it started), for the sake of drawing the flower. You might even use a placeholder of a dot (e.g. forward (1)) for the flower, when figuring out positioning in the wallpaper as a whole Standards: Ostensibly, you'll be graded for following basic coding standards and documentation requirements. At the very minimum: A comment at the top of all source (java) files including your name and student number Variable names that are either standard or descriptive Using things like i and j for loop counters? Standard Using a variable like count? We can guess what you meant For any blocks of code (eg. loops) insert a brief comment so the reader knows what's inside (e.g. what's being repeated) Put a comment in front of any method to briefly explain what it does Anything you think the marker might not understand? Add a quick comment * This probably isn't a concern for this assignment Additionally, try to remember to fix the indentation of your source files. Jagged margins can be harder to follow along with. . Let's first look at the final goal: Turtle Displayer Eile Help Turtle Canvas: Angle: -6.28... Location: (110, 110) Penis: Up Pen Colour Pen Width: 1 Close To achieve this, your Wallpaper program requires a drawwallpaper () method. That drawwallpaper must relocate the turtle to equidistant points, and draw 4x4 flowers. A flower, then, may be drawn via a drawFlower() method, such that: The flower is a random colour The flower is comprised of multiple petals It has a random number of petals, from 4 to 7 (inclusive) * Each petal is drawn as above: equiangular radiating from a single point at equal angles to each other Drawing a petal thus requires its own method, drawPetal(, to draw four lines like so: 30 T1/6 radians If you need a reminder on calculating the length of the hypotenuse for an isosceles right triangle, it's just the square root of double the square of the other side length (in this case, -21.2, but still calculate it) Tips and requirements Even though it's described in pieces above, those are just pieces within the same source file. (i.e. you don't need to submit multiple .java files) For the flower, remember that you're still turning around one full turn overall For the petal, it's imperative to have the turtle end in the same position angle as it started In case random colours haven't been covered in lab, you only need two things: import java.awt.Color; (to get the library) . pen.setPencolor (new Color((int) (Math.random() *16777216))); Though there are a couple places you could set the colour, there's only one correct spot Even though the petal is four lines, I'd advise against trying to put them into a loop; it's more trouble than it's worth Don't use parameters/arguments for your methods . (Depending on when you read this, you may or may not even know what that means) The entire point of this assignment is hierarchical decomposition (breaking down the problem into smaller pieces), so if you skip that step, don't be surprised if you get a zero Your final solution will probably be -60 lines of code. It isn't a challenging assignment, per se, but rather one that reinforces what you learned in lecture/lab/tutorial. It covers a fundamental technique in computer science. Give it the consideration and attention your entire academic future deserves Because you're using procedural abstraction, you might want to consider writing stubs to get the basic components together e.g. you might initially draw a 'petal' as simply a line (that then reverses to return to where it started), for the sake of drawing the flower. You might even use a placeholder of a dot (e.g. forward (1)) for the flower, when figuring out positioning in the wallpaper as a whole Standards: Ostensibly, you'll be graded for following basic coding standards and documentation requirements. At the very minimum: A comment at the top of all source (java) files including your name and student number Variable names that are either standard or descriptive Using things like i and j for loop counters? Standard Using a variable like count? We can guess what you meant For any blocks of code (eg. loops) insert a brief comment so the reader knows what's inside (e.g. what's being repeated) Put a comment in front of any method to briefly explain what it does Anything you think the marker might not understand? Add a quick comment * This probably isn't a concern for this assignment Additionally, try to remember to fix the indentation of your source files. Jagged margins can be harder to follow along with

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Students also viewed these Databases questions