Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a JavaFX Application that draws a row of random circles. Due: Saturday March 16, 2019 Goal: Write a JavaFX Application that draws a row

Write a JavaFX Application that draws a row of random circles.

image text in transcribed

image text in transcribed

image text in transcribed

Due: Saturday March 16, 2019 Goal: Write a JavaFX Application that draws a row of random circles Create a class RandCircle that extends the class Circle of JavaFX. RandCircle has al the methods of Circle (by inheritance) but now adds the methods setRandomFil1), setRandomStroke( and setRandomRadius( double min, double max) to randomly pick a Color for the fill and stroke and picks a random radius in the range min to max. For this, it is OK to randomly pick a value 0..255 for each of red, green, and blue You will need a constructor for this class RandCircle( double centerX, double centerY, double radius) Use super () to use one of Circle's constructors. This must be the first line of a child's constructor, so the radius the constructor gives to a RandCircle is not random. Have only this one constructor. Later in the code, the radius can be randomly picked (or not.) Create an Application that draws a picture with N RandCircles in a row. Make N an easily- changed value and base the location of the RandCircles and the size of the Scene on it. You will likely create a Group as the root of the scene graph Of course, if all you wanted was this particular picture you could do it by using methods of Circle alone and not by creating a new class. But the real purpose of this assignment is to practice inheritance, so create the RandCircle class as a child of Circle You will need a driver program that creates and displays the scene graph. Start programs with a brief documentation header that says what it is, who did it, and when. BlueJ gives you some of this automatically, but you have to fill in some things. Also, include some line-by-line documentation that says what is going on What to turn in: The Java source files only. Don't turn in the entire BlueJ project. import javafx.application.Application; import static javafx.application.Application.launch; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.stage.Stage; public class Circles extends Application { private final int ROWS = 7, COLS 10; private final int WIDTH = 700, HEIGHT = 500; public void start (Stage primaryStage) //creating a group to hold circles Group root = new Group(); //creating a scene Scene scene - new Scene(root, WIDTH, HEIGHT, Color .LIGHTYELLOW); //finding gap between centers of each circle horizontally double XGap = scene . getWidth() / COLS ; //radius of each circle double radius = xGap / 3; //finding gap between centers of each circle vertically double yGapscene.getHeight() / ROWS; //setting starting x and y coordinates double x = XGap / 2, y yGap / 2; /looping through each row and column for (int 1-0; i

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

Students also viewed these Databases questions