Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Random; import java.util.Scanner; public class Question2 { public static void drawPolygon(Turtle turtle, int numSides, int sideLength) { // complete } public static void drawPolygon(Turtle

import java.util.Random;

import java.util.Scanner;

public class Question2 {

public static void drawPolygon(Turtle turtle, int numSides, int sideLength) {

// complete

}

public static void drawPolygon(Turtle turtle, int numSides, double radius) {

}

public static void drawStarBurst(Turtle turtle, int numBursts, int radius) {

// complete

}

public static void conchSpiral( Turtle turtle, int numSides, double sRad, double eRad,

int numSteps, int stepAngle) {

// complete

}

public static void floralSpiral(Turtle turtle, int numSides, double sRad, double eRad,

int numSteps, double stepAngle) {

}

public static void main(String[] args)

{

Turtle bob = new Turtle();

// statements to control bob here and invoke methods here

}

}

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

uestion02 (drawing with iterative loops In Question02, you will write methods that create graphical elements using iteration (the repetition of statements using loops, such as for or while loops) 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 of length 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. uestion02 (drawing with iterative loops In Question02, you will write methods that create graphical elements using iteration (the repetition of statements using loops, such as for or while loops) 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 of length 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

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

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions