Write a method called drawspokes to draw the spokes

Assignment Help JAVA Programming
Reference no: EM13860256

Part A

As part of a package called Assign_3, write a Java class called Forest. For the first part, the class will draw a set of spokes on the display as shown below.

2257_img.png

Write a method called drawSpokes to draw the spokes. The method should take a double parameter that is the radius of the figure (i.e. the length of each spoke). There are 6 spokes, equally spaced around the center. To make Part B easier, make sure leave the turtle back where it started (i.e. at center facing right).

Part B

As the second part of the assignment, modify the Forest class written in Part A so that it draws a tree as seen below (the height is 80 and the canopy radius is 15).

523_img1.png

Write a method drawTree that draws the tree with a light gray trunk and a canopy. The method should take as parameters the height of the trunk and the radius of the canopy.

The trunk is a line drawn of specified height with pen width 10. The canopy is a set of spokes of the specified radius using a pen of width radius*2 using the method drawSpokes from Part A. The drawSpokes method should be modified to draw the spokes in green. Again, to make Part C easier, be sure to leave the turtle where it started.

Part C

As the third part of the assignment, modify the Forest class written in Part B so that it draws a forest of trees evenly spaced across the canvas as seen below:

1912_img2.png

Write a method drawForest that draws the trees using the method drawTree from Part B. The method takes as a parameter the number of trees to draw. Each tree has a randomly selected height between 40 and 100 and canopy radius between 10 and 20. The method is called with a random number of trees between 5 and 10. Use a FAST turtle.

Part D

As the final part of the assignment, modify the Forest class written in Part C so that it draws a forest in fall (i.e. some colored leaves) as seen below:

1787_img3.png

Write a method chooseColor that sets the pen color to green with a 75% probability and red with a 25% probability. Modify the drawSpokes method to call chooseColor rather than setting the pen color to green directly. To make the random selection of color, generate a random number between 0.0 and 1.0 (i.e. what random() returns). If the value is less than 0.75 choose green otherwise choose red. Suggestions:

• The separation into multiple methods with parameters as indicated is mandatory-for a good reason. Build up the program as outlined above rather than trying to get the final result. Procedural abstraction allows you to ignore the details of say how the tree is drawn, when writing the code to draw the forest.

• To make procedural abstraction effective, it is necessary to know where the turtle starts drawing and where it ends up after each method.

Reference no: EM13860256

Questions Cloud

Find the shape and dimensions of country : There are 20,000 hours of labor for country A. 5 hours of labor are required to produce 1 unit of S, while 4 hours are required to produce 1 unit of T. Find the shape and dimensions of country A's PPF.
Innovation is the strategy of innovating in emerging : Reverse Innovation is the strategy of innovating in emerging (or developing) markets and then selling these innovations in developed markets. Companies are developing products in emerging countries like China and India for global distribution. How wi..
How can supply chain management : How can Supply Chain Management (SCM) improve the Five Forces pressing in on the enterprise's room to produce excellent financial results and how can SCM have each effect that you describe, on the Five Forces?  Also please describe how the enterprise..
Distinctions between net ordinary-separately stated income : What are the distinctions between net ordinary income and separately stated income and deductions? What is the rationale for separately stating those items as individual K and the K-1?
Write a method called drawspokes to draw the spokes : Write a method drawForest that draws the trees using the method drawTree from Part B. The method takes as a parameter the number of trees to draw
Change in the total quantity produced : The change in the total quantity produced which results when one more worker is added to the production process is called
Does the government and big business control : To what extent in life can people make choices to suit us and our own good? Or does the government and big business control us, de facto, or not, (and to what extent)?
Composite index for housing construction costs : Prepare a composite (weighted) index for housing construction costs in 2008 with the following data:
Calculate the cost variance-schedule variance : Examine the following EVM data for the Acme project, a hypothetical construction project, to view information on the past and future performance: Calculate the cost variance (CV), schedule variance (SV), cost performance index (CPI), and schedule per..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program that creates an enumeration representing

Sherri rolls a 3 and decides to continue. She then chooses to roll two more times (6, 1). Because she rolled a 1, Sherri's turn ends and she earns 0 points.

  File integrity checker - tripwire

Write a program that will perform some of the basic tasks accomplished by a file integrity checker such as Tripwire.

  Write a method reversefirstk

Write a method reverseFirstK that accepts an integer k and a queue of integers as parameters and reverses the order of the first k elements of the queue, leaving the other elements in the same relative order.

  Consider the problem of finding the position

Consider the problem of finding the position, p, of the last occurrence of a given number, x, in an array, A. We thus want a function FindLast(A,n,x) with precondition

  Create a program that holds a simple address book

Create a class HashTable which implements HashTableInterface with buckets. You can use an array of linked lists(of Person objects).You may add any other methods you think are necessary.

  Considered to be an improved version

Part (c) is considered to be an improved version of Part (b). You may use an array (2-dimessional) to store some values that has been computed during the run so that when making recursive calls the program does not compute certain values over and ..

  Write java program using array list object

Write a java program (using eclipse) using ArrayList object to allow the professor to enter student's name, his or her's four test scores.

  Display the values that were typed in to the form

This assignment will focus on creating Java Server Pages (JSP) and deploying them onto a Java Servlet Container.

  Create a java application that contains methods to display

Create a Java application that contains methods to display statistics for the numbers in an array. The main method has been written and it's attached. complete the program by writing the following methods.

  Determine the number is prime

Determine if the number is prime. If N is prime, then print a message stating that it is prime - If the integer is not between 0 and 8000000, then the program keeps prompting the user to re-enter the number till the integer is within the proper ran..

  How do you provide a link from one class to a related class

How do you provide a link from one class to a related class

  Create a website

The preplanning design consists of a document that defines the element specifically requested by the client and indicates where these features will be located on the Website

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd