Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M91521016
  • Price:- $90

Guranteed 48 Hours Delivery, In Price:- $90

Have any Question?


Related Questions in Java

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As