Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Write Javafx Application Draws Row Random Circles Q35615631

Write a JavaFX Application that draws a row of randomcircles.

Due: Saturday March 16, 2019 Goal: Write a JavaFX Application that draws a row of random circles Create a class RandCircle th

import javafx.application.Application; import static javafx.application.Application.launch; import javafx.scene.Group; import

//using a black border color circle.setStroke(Color.BLACK); //adding to group root.getChildren().add(circle); x +- xGap//incr

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 < ROWS ; i++) { for (int j – 0; j < COLS, j++) { //creating a circle Circle circle – new Circle(x, y, radius); ///creating a random color Color cnew Color (Math.random), Math. random(), Math.random(),1); //using it as fill color circle.setFill(c); //using a black border color circle.setStroke(Color.BLACK); //adding to group root.getChildren().add(circle); x +- xGap//incrementing x by xGap distance //resetting x xxGap 12 //incrementing y by yGap distance y yGap; primaryStage.setScene (scene); primaryStage.setTitle(“Circles”); primaryStage.show(); public static void main(String[] args) launch (args): Show transcribed image text 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

Leave a Reply

Your email address will not be published. Required fields are marked *