Question: I can only use loops and the API from https://sites.google.com/a/asmsa.org/turtle/class-documentation/documentation I could really use the solution for this. a) Create a method drawPolygon(Turtle turtle, int

 I can only use loops and the API from https://sites.google.com/a/asmsa.org/turtle/class-documentation/documentation I

I can only use loops and the API from

https://sites.google.com/a/asmsa.org/turtle/class-documentation/documentation

I could really use the solution for this.

a) Create a method drawPolygon(Turtle turtle, int sideLength, int numsides) that will draw a regular polygon with numSides sides (i.e. a polygon where all numSides sides are of equal length given by the argument sideLength). You should be able to see from Question01, that there is a pattern in drawing both the equilateral triangle and the square. In this method, you should use a loop (e.g. FOR loop) in order to instruct the turtle to draw the polygon. The recipe (algorithm) for drawing a polygon is summarized in Fig.3. Note that the POLYGON algorithm shows a recipe for drawing a polygon with N sides, each oflength 1. The angles between each of the sides is thus 2T/N (radians), which is equivalent to (360/N degrees). If heading clockwise, the turn should be to the right within each repetition. POLYGON N REPEAT N TIMES FORWARD I TURN 2/N Fig. 3 Create a turtle in your main method, and invoke the drawPolygon method several times to draw several polygons for N-3, 5, 8 (with side lengths: 200, 200, 100 respectively) You should see the following results for each

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!