Table of Contents Part 1.................................................................................................................................................4 Design................................................................................................................................................4 Design Requirements.........................................................................................................................4 Testing...............................................................................................................................................4 Code:.................................................................................................................................................5 Part 2.................................................................................................................................................6 Design................................................................................................................................................6 Code:.................................................................................................................................................7 Screenshot.........................................................................................................................................8 References.........................................................................................................................................8
Part 1 Design 1.Develop an applet that displays a dartboard pattern like the one shown here, with equally spaced concentric circles and radial lines. The applet must check the available width and height, so that the pattern is drawn as large as possible. There should always be three equally spaced circles, but the number of lines must be specified by a parameter in the
HTML file. The number of lines should be between 2 and 30, and should default to 20 if outside of these limits. Design Requirements ï‚·Get the Height and Width parameters, check to see which is the smallest and this will be the diameter ï‚·Draw circle using this Diameter, repeat using 1/3 of this diameter, and using 2/3 of this diameter. ï‚·Get the number of lines, check to ensure these are within the defined parameters of 2 and 30 inclusive, if not set to 20 ï‚·Find the number of points on the circle (Lines *2) ï‚·Derive the angle to step through for each point (360/the number of points) ï‚·Loop to run for each number of points ï‚·Get the line angle in radians = (angle* i) * Pi/180 ï‚·Get the X coordinate of the point (Radius * Cos (Radians)) ï‚·Get Y coordinate (Radius * Sin (Radians)) ï‚·Draw line ((X + Radius), (y+Radius) (x centre), (y centre)) Testing
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Screenshot References Part 1 Deitel, P and Deitel, H. (2011)Java How to Program, London: Pearson Education M.U.A. Part 2 Code Samples: https://www.javacodex.com/More-Examples/2/10[accessed 27.3.19] https://docs.oracle.com/javase/tutorial/uiswing/painting/closer.html[accessed 27.3.19] https://way2java.com/java-general/java-set-background-color/[accessed 27.3.19]